From 24d16eed9dd940873b570b630a882e477d225bb6 Mon Sep 17 00:00:00 2001 From: Mason Ray Hanna III Date: Mon, 17 Apr 2023 16:54:52 -0400 Subject: [PATCH] This commit resolves issue #10655 Fixed errors and lack of documentation in mod.rs. Added type check and test case for string slice. Added supposed check for windows paths. Build failure fix. Build fix attempt #2. Fixed formatting. Refactor unwind from Option to a new enum Fix tools Make elaborator generic Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup Tweak output for 'add line' suggestion Special-case item attributes in the suggestion output resolve: Pre-compute non-reexport module children Instead of repeating the same logic by walking HIR during metadata encoding. The only difference is that we are no longer encoding `macro_rules` items, but we never currently need them as a part of this list. They can be encoded separately if this need ever arises. `module_reexports` is also un-querified, because I don't see any reasons to make it a query, only overhead. Alloc `hir::Lit` in an arena to remove the destructor from `Expr` This allows allocating `Expr`s into a dropless arena, which is useful for using length prefixed thing slices in HIR, since these can only be allocated in the dropless arena and not in a typed arena. This is something I'm working on. clippy: add test for /~https://github.com/rust-lang/rust-clippy/issues/10645 Remove very useless `as_substs` usage from clippy Force -Zflatten-format-args=no in Clippy. Remove WithOptconstParam. offset_of Evaluate place expression in `PlaceMention`. Allow `LocalDefId` as the argument to `def_path_str` Merge commit 'a3ed905928a03b6e433d0b429190bf3a847128b3' into clippyup Clippy book: hotfix for broken link change usages of explicit_item_bounds to bound_explicit_item_bounds add EarlyBinder to output of explicit_item_bounds; replace bound_explicit_item_bounds usages; remove bound_explicit_item_bounds query add subst_identity_iter and subst_identity_iter_copied methods on EarlyBinder; use this to simplify some EarlyBinder noise around explicit_item_bounds calls rename `needs_infer` to `has_infer` Make clippy happy uplift `clippy::clone_double_ref` as `suspicious_double_ref_op` clean up Colon from clippy Restrict `From` for `{D,Subd}iagnosticMessage`. Currently a `{D,Subd}iagnosticMessage` can be created from any type that impls `Into`. That includes `&str`, `String`, and `Cow<'static, str>`, which are reasonable. It also includes `&String`, which is pretty weird, and results in many places making unnecessary allocations for patterns like this: ``` self.fatal(&format!(...)) ``` This creates a string with `format!`, takes a reference, passes the reference to `fatal`, which does an `into()`, which clones the reference, doing a second allocation. Two allocations for a single string, bleh. This commit changes the `From` impls so that you can only create a `{D,Subd}iagnosticMessage` from `&str`, `String`, or `Cow<'static, str>`. This requires changing all the places that currently create one from a `&String`. Most of these are of the `&format!(...)` form described above; each one removes an unnecessary static `&`, plus an allocation when executed. There are also a few places where the existing use of `&String` was more reasonable; these now just use `clone()` at the call site. As well as making the code nicer and more efficient, this is a step towards possibly using `Cow<'static, str>` in `{D,Subd}iagnosticMessage::{Str,Eager}`. That would require changing the `From<&'a str>` impls to `From<&'static str>`, which is doable, but I'm not yet sure if it's worthwhile. Use `ty::TraitRef::new` in clippy Fix uses of `TraitRef::identity` in clippy and rustdoc Rename std::mem::size_of_value to std::mem::size_of_val Suggest applicable expression for manual slice size calculation lint Add run-rustfix marker and test file Use `clippy_utils::std_or_core` in manual slice size calculation lint Ignore `manual_slice_size_calculation` in code from macro expansions Add size-parameter to unecessary_box_returns Fixes #10641 Suppress the triggering of some lints in derived structures Address comments Update version attribute for 1.69 lints Changelog for Rust 1.69 :cherry_blossom: [arithmetic_side_effects] Fix #10590 Update to a compiletest-rs version that requires `//@` for commands [arithmetic_side_effects] Cache symbols Fix typo in significant_drop_tightening Fix `#[allow(clippy::enum_variant_names)]` directly on variants make [`len_zero`] lint not spanning over parenthesis clippy: drop unused semver crate Ignore `impl Trait`(s) Add lint `items_after_test_module` Compact emmited lint Bump Clippy version -> 0.1.71 Bump nightly version -> 2023-04-23 Fix dogfood test Dont suggest suboptimal_flops unavailable in nostd Fixes #10634 use is_inside_const_context query for in_constant split test into 2 Remove check for `lib.register_*` and `src/docs*` in `cargo dev update_lints` This reverts commit 22d435b26627c1085c5b761846ca08870288794f. Detect if expressions with boolean assignments to the same target Spelling * applying * binding * complex * constituent * demonstrate * desugaring * exact * expression * for * functionalities * github * implementation * infers * multiple conflicting traits * mutable * necessarily * nightly * nonexistent * optional * parameter * reassignments * resources * substitution * suggestion * that * that array is * using the Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com> Rewrite search_same description Ignore `shadow` warns in code from macro expansions fix false positive Update allow_attributes_false_positive.rs also check for rest pat in `redundant_pattern_matching` Improve the help message + add a help span don't check if from macro invocation run cargo dev fmt make cargo test pass use in_external_macro Catching, stray, commas, (I'll, never, learn, to, use, them, correctly) :sweat_smile: Add the warning to all documentation. add `semicolon_outside_block_if_singleline` lint make cargo test pass refactor make cargo test pass, again improve description a bit refactor config instead of new lint and don't panic make cargo test pass change names to not be implicitly negative use `//@` for commands in tests Update lint_configuration.md run linkcheck in Remark CI fix new lints link install nightly rust-docs run linkcheck without nightly toolchain remove nightly toolchain, add rust-docs component Test Remark Update basics.md Update basics.md Update basics.md update workflow add rust docs toolchain Update remark.yml workflow test manual test update book path add linkcheck book to CI Update lint_passes.md Fix #10713 and move the tests to a subdir Remove useless span magic Change module import system Rename items + Delete `imported_module.stderr` new lint: `while_pop_unwrap` elide lifetimes, get rid of glob import move lint to loops, emit proper suggestion, more tests remove unnecessary reference make PopStmt copy+clone rename lint to `manual_while_let_some` fix run-rustfix directive Clarify docs for RESULT_LARGE_ERR globally ignore `#[no_std]` crates Don't ignore `check_radians` Update macros.rs adds lint to detect construction of unit struct using `default` Using `default` to construct a unit struct increases code complexity and adds a function call. This can be avoided by simply removing the call to `default` and simply construct by name. fix diagnostic message style Co-authored-by: Ruby Lazuli fixed span and corrected test output rename to plural form add more test cases fix failing tests add `rustfix` annotation fix lint docs Inherit stdout/stderr for `cargo dev dogfood` Bump nightly version -> 2023-05-05 Ignore expressions from macros in default_constructed_unit_structs new lint: clippy::ref_patterns Add missing word "are" Ignore `borrow_deref_ref` warnings in code from procedural macros. `Wildcard_imports` ignore `test.rs` files Really mini minor irrelevant change for formatting Now the lint ignores any crates with `--cfg test` Fix header Bump README copyright wip WIP WIP WIP Working Update trait_bounds.rs Update trait_bounds.rs Comments Comments Minimizing changes Fix config formatting, less indenting, more spacing needless_bool: do not simplify code if it loses comments add lint `manual_next_back` checks for manual reverse iteration (`.rev().next()`) of a `DoubleEndedIterator` Update actions/checkout Update actions/setup-node fix: warn on empty line outer AttrKind::DocComment changelog: [`empty_line_after_doc_comments`]: add lint for checking empty lines after rustdoc comments. Fixes: #10395 Consider referenced allowed or hard-coded types fix #10773 move `is_ty_alias` to `clippy_utils` flip1995: Stepping down from the reviewer rotation A step I was trying to avoid for way too long, but sadly necessary now. I hope I can come back stronger in a few months. Rebase and merge attempt number 2. Included sources to std::path in lint string. Rebase and merge attempt number 2. Fixed arguments in lint string. Renamed lint to join_absolute_path as per request. Ran cargo dev update_lints Ran cargo dev bless after a full cargo test Entered supposed changes, ran cargo dev fmt, test, and bless. initial step towards implementing C string literals rm diag item, use lang item Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup Make the BUG_REPORT_URL configurable by tools This greatly simplifies how hard it is to set a custom bug report url; previously tools had to copy the entire hook implementation. - Switch clippy to the new hook This also adds a `extra_info` callback so clippy can include its own version number, which differs from rustc's. - Call `install_ice_hook` in rustfmt make (try_)subst_and_normalize_erasing_regions take EarlyBinder changes from review: add FIXME to clippy and change subst_identity to skip_binder in mir subst methods IAT: Introduce AliasKind::Inherent Drop uplifted clippy::drop_ref Drop uplifted clippy::drop_copy Drop uplifted clippy::forget_ref Drop uplifted clippy::forget_copy Exposes false negative in clippy's diverging_sub_expression Remove `LangItems::require` It's just a short wrapper used by `tcx.require_lang_item`. Deleting it gives us a negative diff. Exclude inherent projections from some alias ty matches Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup Rename `drop_copy` lint to `dropping_copy_types` Rename `forget_copy` lint to `forgetting_copy_types` Rename `drop_ref` lint to `dropping_references` Rename `forget_ref` lint to `forgetting_references` Replace EarlyBinder(x) with EarlyBinder::new(x) Make EarlyBinder's inner value private; and fix all of the resulting errors Use `Cow` in `{D,Subd}iagnosticMessage`. Each of `{D,Subd}iagnosticMessage::{Str,Eager}` has a comment: ``` // FIXME(davidtwco): can a `Cow<'static, str>` be used here? ``` This commit answers that question in the affirmative. It's not the most compelling change ever, but it might be worth merging. This requires changing the `impl<'a> From<&'a str>` impls to `impl From<&'static str>`, which involves a bunch of knock-on changes that require/result in call sites being a little more precise about exactly what kind of string they use to create errors, and not just `&str`. This will result in fewer unnecessary allocations, though this will not have any notable perf effects given that these are error paths. Note that I was lazy within Clippy, using `to_string` in a few places to preserve the existing string imprecision. I could have used `impl Into<{D,Subd}iagnosticMessage>` in various places as is done in the compiler, but that would have required changes to *many* call sites (mostly changing `&format("...")` to `format!("...")`) which didn't seem worthwhile. Drop uplifted clippy::invalid_utf8_in_unchecked EarlyBinder::new -> EarlyBinder::bind Drop uplifted clippy::cast_ref_to_mut Use translatable diagnostics in `rustc_const_eval` Implement custom diagnostic for ConstParamTy Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup Rename `impl_defaultness` to `defaultness` Removed stable/unstable sort arg from into_sorted_stable_ord, fixed a few misc issues, added collect to UnordItems Whoops, submodule change was actually valid - undoing fixup Drop uplifted clippy::undropped_manually_drops Drop uplifted `clippy:cmp_nan` Extend `unused_must_use` to cover block exprs Add `AliasKind::Weak` for type aliases. Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases. Move WF goal to clause Move ConstEvaluatable to Clause Treat TAIT equation as always ambiguous in coherence Better error for non const `PartialEq` call generated by `match` Make `{Arc,Rc,Weak}::ptr_eq` ignore pointer metadata s/Clause/ClauseKind Support `ast::ExprKind::Become` in clippy Migrate item_bounds to ty::Clause Do not offer any of the suggestions in emit_coerce_suggestions for expr from destructuring assignment desugaring Support `hir::ExprKind::Become` in clippy Migrate predicates_of and caller_bounds to Clause Provide more context for `rustc +nightly -Zunstable-options` on stable Make simd_shuffle_indices use valtrees Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup Fix valtree changes Fix compile-test tests to work with the new ui_test crate Deal with fallout Patch clippy Move `TyCtxt::mk_x` to `Ty::new_x` where applicable Fix failing clippy tests Comments out the C string literals due to /~https://github.com/rust-lang/rust/pull/113334 Fixes /~https://github.com/rust-lang/rust-clippy/issues/11121 Rename `adjustment::PointerCast` and variants using it to `PointerCoercion` It makes it sound like the `ExprKind` and `Rvalue` are supposed to represent all pointer related casts, when in reality their just used to share a some enum variants. Make it clear there these are only coercion to make it clear why only some pointer related "casts" are in the enum. Delete `to_string_in_format_args_incremental.rs` It fails CI and passes locally. It passes random directores in `-Cincremental` so maybe something's up. It shouldn't block us here. Drop uplifted `clippy::fn_null_check` Ignore flaky clippy tests. Suggest the correct variable name for `manual_let_else` Split if conditions by its semantics Remove old feature flag in code comment Since let_else feature has been stable in 1.65.0, it's now unnecessary Avoid renaming for TupleStruct with multiple arguments update spec fix: move specs in fire Fix: Some suggestions generated by the option_if_let_else lint did not compile bump up `regex-syntax` dependency version to 0.7.0 Ignoring `let_underscore_untyped` warnings in code from proc macros fixing fmt Checking for proc_macro not only when local.init is Some Remove unnecessary from example fix example heading in `string_slice` don't remove `dbg!` in arbitrary expressions handle nested macros and add tests for them Rename integer_arithmetic redundant_pattern_matching redundant_pattern_matching fix conflict with matches macro fix conflict with matches macro fix error test update a func fix reviewer comments fix reviewer comments: tests results update tests update test option Don't suggest unnameable types in box_default, let_underscore_untyped Search for inactive `cfg` attributes and empty macro expansion through the entire block Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements. Improve `SpanlessEq` * Don't consider expansions of different macros to be the same, even if they expand to the same tokens * Don't consider `cfg!` expansions to be equal if they check different configs. enhance `needless_collect` Updates `needless_collect` to lint for collecting into a method or function argument thats taking an `IntoIterator` (for example `extend`). Every `Iterator` trivially implements `IntoIterator` and colleting it only causes an unnecessary allocation. Add new `UNIQUE_CFG_CONDITION` lint Add UI test for UNIQUE_CFG_CONDITION Update CHANGELOG Add check for empty cfg `all` condition Update urls in Type Checking Bump nightly version -> 2023-05-20 [`match_wild_err_arm`]: do not lint in const contexts consider array initializer for `large_stack_arrays` add test case for #10741 Unit tests highlighting unsafe match issue These unit tests generate non-compilable code. I did NOT `bless` them on purpose because the stderr output is not good. I'm surprised we don't auto-compile the suggestions here - is this something that can be easily enabled? See #10808 Fix unsafe blocks Use #[rustfmt::skip] remove todo Run-rustfix needless_else: new lint to check for empty else clauses the implementation!! check msrv Update clippy_lints/src/casts/ptr_cast_constness.rs Co-authored-by: llogiq add description and rename msrv tests change `clippy::version` to 1.71.0 Display the `needless_return` suggestion error out if lint name contains dash replace `-` instead of erroring out apply suggestion Co-authored-by: Philipp Krones Address Dependabot alerts do not consider `await` in nested `async` blocks remove old span_lint point to `await` expr in note redundant pattern matches! result [`default_constructed_unit_structs`]: do not lint type aliases Ignore #[cfg]'d out code in needless_else Fix formatting of if let chain Some improvements to the manual_let_else lint suggestions * Replace variables inside | patterns in the if let: let v = if let V::A(v) | V::B(v) = v { v } else ... * Support nested patterns: let v = if let Ok(Ok(Ok(v))) = v { v } else ... * Support tuple structs with more than one arg: let v = V::W(v, _) = v { v } else ... * Correctly handle .. in tuple struct patterns: let v = V::X(v, ..) = v { v } else ... Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases Update version attribute for 1.70 lints Changelog for Rust 1.70 :hammer: Change changelog typos Co-authored-by: Takayuki Nakata deps: drop serde feature from url actually, remove rustc-workspace-hack dependency too [`wildcard_imports`] Modules that contain `prelude` are also allowed This commit fixes #10846 by checking if the path segment contains the word "prelude". Signed-off-by: Charalampos Mitrodimas fix issues 10836 change booleans file and update tests Remove lint name and category fields from the new lint issue form new lint: `missing_field_in_debug` move some strings into consts, more tests s/missing_field_in_debug/missing_fields_in_debug dont trigger in macro expansions make dogfood tests happy minor cleanups replace HashSet with FxHashSet replace match_def_path with match_type if_chain -> let chains, fix markdown, allow newtype pattern fmt consider string literal in `.field()` calls as used don't intern defined symbol, remove mentions of 'debug_tuple' special-case PD, account for field access through `Deref` don't lint enums, update note in lint description Explain which paths clippy searches for configuration in docs Explain path-search using a list Add spans to `clippy.toml` error messages Bump nightly version -> 2023-06-02 Bump Clippy version -> 0.1.72 add checking for cfg(features = ...) Update *Current stable* text in `CHANGELOG.md` Refresh Lint Configuration's looks emit `unnecessary_cast` on raw pointers as well ok actually appease CI I should always run cargo test before committing :sweat_smile: add generics in test also ensure generics with the same type are linted Use URL parameters for filter states This retains the settings during browser navigation and allows sharing links with additional configuration. Handle back/forward when using URL parameters for filter states Clippy Lints page - Delay updating of the URL in response to search input Update on blur, enter keypress, and a debounced delay of 1000 ms. This keeps the URL updated, but not distractingly so. Clippy Lints page - Do not show groups in URL parameters if reset to defaults Clippy Lints page - Fix path watch triggering Clippy Lints page - Do not show filters in URL if configured as default values only lint when `cast_from` and `cast_to`'s ty are the same weird manual_let_else: only add () around PatKind::Or at the top level At the top level, () are required, but on the levels below they are not. Support multi-binding situations as well as tuple patterns Support struct patterns new lint: `explicit_into_iter_fn_arg` dogfood update docs, simplify arg->param map, dont lint on chain merge `explicit_into_iter_fn_arg` into `useless_conversion` fix new failing proc macro tests add plural form to useless_conversion if depth > 0 Add lint to check lint formulation messages Fix lints that don't conform to the standard formulation refactor(test): Move attribute to lint level Fix suggestion on fully qualified syntax ignore `Foo::deref` altogether Add from_over_into replace for type in `Self` reference Ignore from_over_into if it contains Self Move bail into lint to prevent no-linting, move to unfixable don't lint `allow_attributes` on attributes from proc macros foiled again (forgot to run cargo test) Fix `attr_search_pat` for `#[cfg_attr]` remove tuple add test for `?` desugaring Update allow_attributes_without_reason.rs `to_xx_bytes` implemented, `from_xx_bytes` todo Mentioned in #10765 implement `host_endian_bytes` and the other two weird grammar refine output unidiomatic `if_chain!` don't allocate the names use enum for `prefix` instead of `&str` Update endian_bytes.rs derive Copy/PartialEq for `Prefix` Remove `CARGO_UNSTABLE_SPARSE_REGISTRY` env from ci It is now the default to use the sparse registry Move redundant_clone to nursery Add a test that checks for old style test headers [`unnecessary_lazy_eval`]: don't lint on types with deref impl Bring up Rust lang #37612 as a known problem for let_and_return Compact issue link Co-authored-by: Takayuki Nakata Add redundant type annotations lint Move `redundant_type_annotations` to restriction Extract common logic to function Add support to returned refs from `MethodCall` Add `Limitations` section make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size add more info link Fix #10498 Use type snippet instead of init expr for proc macro check check for `_` instead account for autoderef in eager_or_lazy don't call `type_of` on generic params Don't warn if there is a comment between else and curly bracket make `useless_vec` smarter allow the lint in a bunch of tests don't allow `as_slice` for now Adds new lint `arc_with_non_send_or_sync` Updating documentation and lint formatting. Adding extra check to ignore generic args. Swapping to matches macro. handle RangeInclusive function desugar actually don't lint for inclusive range Fix `useless_vec` suggestion in `for _ in vec![..]` Ignore more pointer types in `unnecessary_cast` check that the adjusted receiver type matches target add the `excessive_*` style lints change it to nursery category add `excessive_nesting` Close code block in example couple more notes decided against reinventing the wheel check non-inline modules, ignore all macros work with lint attributes move to `complexity` but don't lint by default Check if from proc macro and better tests remove revisions fix #10776 actually fix it also lint single expression blocks Update mixed_read_write_in_expression.rs Update diverging_sub_expression.stderr ensure there are no stmts for expr check refactor Update excessive_nesting.rs Update excessive_nesting.rs allow disabling module inception on private modules allow disabling module inception on private modules Direct towards late passes in `cargo dev new_lint` handle exponent without digits add test ignore more type aliases in unnecessary_cast ignore more type aliases in unnecessary_cast Update unnecessary_cast.stderr Add `needless_if` lint make cargo test pass add description add description don't lint on `if let` don't lint on `if let` Update needless_if.fixed Stop visiting once it's found `Let` Extend `explicit_iter_loop` to all types Split `for_loops` tests Fix `explicit_into_iter_loop` with mutable references Reborrow mutable references in `explicit_iter_loop` Fix #10504, don't lint on derived code refactor Update trait_bounds.rs `ty_search_pat` `impl WithSearchPat for Ty` Update check_proc_macro.rs Add lint `single_letter_idents` rename the lint make cargo test pass + example ignore generics and allow arbitrary threshold make it work for locals as well oopos add to tests and configuration `cargo collect-metadata` refactor and add link to issue new lint: `large_stack_frames` `cargo dev update_lints` fmt use span_lint_and_note rename "drawbacks" to "known issues" make lint description easier to read, prevent ICE fix rebase weirdness update lint_configuration.md Don't ling `as_conversions` in proc macros [`useless_vec`]: detect unnecessary `vec![_]` add- and fix existing tests Add test code Boilerplate for the new lint Add hook Add the lint to the lib Implement the lint Implement the lint for expect Implement the suggestion Recognize `Ok` Recognize `unwrap_or` methods Recognize `unwrap_or_else` method Track init and unwrap of expr Recognize `Err` Support suggesting panics Add more tests Preserve type annotations when present Fix all the other tests Don't lint non-statement/faux empty `needless_if`s Now `cargo collect-metadata` updates the `CHANGELOG.md` Remove dead code in `needless_pass_by_value` Fix `missing_const_for_fn` not checking `~const Destruct` use trait solver instead; created spaghetti code cleanup spaghetti code remove unnecessary checks remove `in_move` [`needless_lifetimes`]' suggestion now points at the lifetimes [`no_effect`]: suggest adding `return` if applicable make cargo test pass Revert "Make it `Unspecified`" This reverts commit 774863041c1878ab7fb6e27c1c61c04de0e25bc8. Make it `Unspecified` [`map_unwrap_or`]: don't lint when referenced variable is moved Ignore `main()` in `no_test` code fences run `cargo dev fmt` add main function to test itself [`derivable_impls`]: don't lint if expr unsize-coerces fmt dogfood fix internal lints Add lint [`single_range_in_vec_init`] refactor a bit [`unnecessary_fold`]: suggest turbofish if necessary get rid of unnecessary function pointer move check_fold_with_op function out from_over_into: Show suggestions for non-Self expanded paths [`match_same_arms`]: don't lint if `non_exhaustive_omitted_patterns` formatting :/ new lint: `drain_collect` take into account reborrowing when inserting `&mut` in sugg make clippy happy add a description add test case for not whole length, move sugg into variable add lint [`needless_clone_impl`] Update needless_impls.rs rename lint and disallow `clone_from` missing_panics_doc: pickup expect method bless address or allow clippy::missing_panics_doc in clippy-dev merge test improve grammer in comment sentence Co-authored-by: dswij Refactor to make following commit pass single_match_else lint Make `--explain` subcommand return 1 for missing lints Ignore more type aliases in `unnecessary_cast` Adapt versions.html file to cleaned up gh-pages Fix version.py after deleting v* dirs I missed updating this file. I also ran black and isort over it. Adding configuration to allow safety comment above stmt containing unsafe block Addressing reviewer comments adding all ui tests to the configuration test as well Collecting metadata Exlude `todo!()` from `missing_panics_in_doc` `missing_panics_in_doc` bless test and add additional macro testcase new lint `single_call_fn` add test for closures Ignore functions annotated with `#[test]` Fix `find_format_arg_expr` when incremental compilation is enabled Fix #10792 Dogfood Fix false positive of [self_named_module_files] and [mod_module_files] Move continue into if statement Co-authored-by: Catherine <114838443+Centri3@users.noreply.github.com> [`redundant_closure_call`]: handle nested closures fix docs don't unnecessarily walk more in visitor and add more tests Ignore in-proc-macros items use PlaceRef abstractions add non-test-case for suggesting const on functions accessing union fields allow safety comment above attributes [`single_match`]: don't lint if block contains comments add test for block comment and add note to description Don't lint `excessive_precision` on inf Add WebAssembly to allowed idents add WebAssembly to test [`borrow_as_ptr`]: Ignore temporaries use rustc's criteria for a temporary Don't lint `iter_nth_zero` in `next` include a ref if argument is not just a numeric literal use let chains, move assignments out of block, add tests declare needs_ref later [`type_repetition_in_bounds`]: respect msrv for combining maybe bounds put issue link between <> rename MSRV alias, add MSRV to lint doc update lint configuration Don't lint `ptr_arg` when return type uses Cow's lifetime [`format_push_string`]: look through match, if, if-let Avoid linting on procedural macros Lint `mem_forget` if fields are `Drop` move to `drop_forget_ref` make note less verbose Check if `if` conditions always evaluate to true in `never_loop` update changelog's data ranges Port clippy away from compiletest to ui_test Update tests Find the right `cargo-clippy` binary in CI Don't lint code from external macros add `needless_raw_string_hashes` lint add semicolon in doctest new lint `needless_raw_string` + refactor a bit Thanks, #112373, for the snippet at line 75! Update raw_strings.rs don't lint `needless_raw_string_hashes` when it's unnecessary change category and refactor Update raw_strings.rs Revert "new lints for visibility" This reverts commit 0e5a537d209727169769dc19cf86aef27122c092. new lints for visibility Fix compile-test under cargo nextest Add BLESS for compile-test and some cleanup new lint: `manual_range_pattern` manual_range_pattern -> manual_range_patterns Use substring matching for TESTNAME new lints for visibility Change category and update to `ui_test` [`unused_async`]: don't lint on async trait impls move `is_in_trait_method` to utils and rename [`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>` allow dead code in the test [`question_mark`]: don't lint inside of `try` block lint in nested bodies if `try` is in outer body suggests `is_some_and` over `map().unwrap_or(false)` changed the msrv to 1.70 to suggest `is_some_and` if the msrv is not >= 1.70 then the `map_or` is suggested instead of `is_some_and` (even when `unwrap_or` returns false) now passes dogfood by wrapping unwrap_recv and unwrap_arg into a tuple was previously failing due to `check` having to many arguments. Revert "now passes dogfood by wrapping unwrap_recv and unwrap_arg into a tuple" This reverts commit 7b91844a3207d90d4200a7b53d0ae1a7a1dca73a. ignore too_many_arguments on `check` changed msrv name for consistency & changed nested if for style updated list of lints that use msrv ran `cargo collect-metadata` New lint [`redundant_rest_pattern`] Rename the lint Add note to remove `if` statement altogether Fix #10413 Dogfood Bump nightly version -> 2023-06-29 Make `eq_op` suggest `.is_nan()` New lint `tuple_array_conversions` Add msrv check and make test pass Fix FP heavily refactor New lint `manual_try_fold` Add msrv tests Typo update docs address comments Fix typos Use `cargo build --tests` in CI let_and_return: lint 'static lifetimes, don't lint borrows in closures Add `SPEEDTEST` Fix dogfood Finally fix dogfood [`missing_fields_in_debug`]: make sure `self` is an adt new lint: `type_id_on_box` that was definitely not the right version add it to the methods lint pass add a few more test cases s/is_dyn_trait/is_dyn_any [`arc_with_non_send_sync`]: look for nested type parameters [`useless_vec`]: use the source span Don't lint manual_let_else in cases where the question mark operator would work Also, lint question_mark for `let...else` clauses that can be simplified to use `?`. This lint isn't perfect as it doesn't support the unstable try blocks. Fix the now stricter lint in manual_rem_euclid.rs Put into one pass Don't suppress manual_let_else if question_mark is allowed If question_mark is allowed, there is no overlap any more, so we can just not suppress it. Move pat_and_expr_can_be_question_mark into clippy_utils Fix FP [`needless_raw_string_hashes`] [`useless_vec`]: add more tests for macro combinations new lint: `read_line_without_trim` add test cases for u32, f32, bool, String Fix regex lints for regex 1.9.0 arc_with_non_send_sync: reword and move to suspicious Pass correct substs to `implements_trait` in `incorrect_impls` `Copy` does in fact not exist. The substs on the trait_ref contain the `Self` type of the impl as the first parameter, so passing that to `implements_trait`, which then nicely prepends the `Self` type for us does not end will. Fix changelog PR listings, create them automatically in `fetch_prs_between.sh` implement `manual_partial_ord_impl` first try at this rename to `manual_partial_ord_and_ord_impl` cargo dev fmt cargo test passes cargo test passes refactor a lil Update bool_comparison.stderr heavily refactor + bump `clippy::version` refactor refactor check bounds to increase accuracy, and add todos use `other` instead of `self` refactor `manual_float_methods` Make suggestion give multiple alternatives Refactor, remove `Constant::to_bits` [significant_drop_tightening] Fix #11128 Dogfood Add test for #10535 Fix #10535 Add needless_pass_by_ref lint Add UI test for `needless_pass_by_ref_mut` Update UI tests with new `needless_pass_by_ref_mut` lint Fix warnings of `needless_pass_by_ref_mut` in clippy Add warning for `NEEDLESS_PASS_BY_REF_MUT` lint about the fact that it changes API Add warning about semver compatibility if it's a public function "try this" -> "try" [`unnecessary_literal_unwrap`]: don't lint if binding initializer is expn [`manual_range_patterns`]: lint negative values [`manual_range_patterns`]: document what range we don't lint changelog: Fix typo in `needless_pass_by_ref_mut` lint description adjust applicability and suggest making binding mutable Use depinfo to discover UI test dependencies [`unnecessary_literal_unwrap`]: lint `unwrap_unchecked` [`unnecessary_literal_unwrap`]: also handle unwrap_err_unchecked Update version attribute for 1.71 lints Changelog for Rust 1.71 :crown: Changelog: Add disclaimer about the new format [`panic_in_result_fn`] remove `todo!`, `unimplemented!`, `unreachable!` This commit fixes #11025 by removing checks for `todo!`, `unimplemented!` and `unreachable!`. Signed-off-by: Panagiotis Foliadis Add "Known problems" section to `needless_borrow` documentation [`tuple_array_conversions`]: move from `complexity` to `nursery` Due to outstanding issues: * /~https://github.com/rust-lang/rust-clippy/issues/11082 * /~https://github.com/rust-lang/rust-clippy/issues/11085 * /~https://github.com/rust-lang/rust-clippy/issues/11100 (/~https://github.com/rust-lang/rust-clippy/pull/11105) * /~https://github.com/rust-lang/rust-clippy/issues/11124 * /~https://github.com/rust-lang/rust-clippy/issues/11144 [`arithmetic_side_effect`]: allow different rhs type Add `imports_granularity = "Module"` to rustfmt.toml Trigger a rebuild when CLIPPY_CONF_DIR changes Set `unnecessary_cast` suggestion to `MaybeIncorrect` for pointer casts Removing casts may cause type inference to stop working which requires manual intervention Bump Clippy version -> 0.1.73 Bump nightly version -> 2023-07-14 renamed lint Removed if chain. Added the rest of the suggested changes. Applied cargo test supposed changes. Resolved rest of changes. Resolved nitpicks. Update clippy_lints/src/methods/join_absolute_paths.rs Co-authored-by: Catherine Flores Formatted and blessed. Got rid of println! calls. Rebase attempt number 2 --- CHANGELOG.md | 147 ++ Cargo.toml | 21 + book/src/configuration.md | 25 + book/src/development/adding_lints.md | 25 + book/src/development/lint_passes.md | 16 + book/src/lint_configuration.md | 219 +++ clippy_dev/src/main.rs | 26 + clippy_lints/Cargo.toml | 22 + clippy_lints/src/allow_attributes.rs | 31 + clippy_lints/src/arc_with_non_send_sync.rs | 141 ++ clippy_lints/src/assertions_on_constants.rs | 11 + clippy_lints/src/attrs.rs | 178 ++ clippy_lints/src/bool_assert_comparison.rs | 8 + clippy_lints/src/booleans.rs | 60 + clippy_lints/src/casts/borrow_as_ptr.rs | 22 + clippy_lints/src/casts/cast_possible_wrap.rs | 59 + clippy_lints/src/casts/mod.rs | 42 + clippy_lints/src/casts/ptr_cast_constness.rs | 97 + clippy_lints/src/casts/unnecessary_cast.rs | 126 ++ clippy_lints/src/dbg_macro.rs | 81 + clippy_lints/src/declared_lints.rs | 97 + .../src/default_constructed_unit_structs.rs | 52 + clippy_lints/src/dereference.rs | 37 + clippy_lints/src/derivable_impls.rs | 91 + clippy_lints/src/doc.rs | 16 + clippy_lints/src/drop_forget_ref.rs | 96 + clippy_lints/src/endian_bytes.rs | 503 +++++ clippy_lints/src/excessive_nesting.rs | 557 ++++++ clippy_lints/src/incorrect_impls.rs | 16 + clippy_lints/src/items_after_test_module.rs | 131 ++ clippy_lints/src/large_stack_frames.rs | 155 ++ clippy_lints/src/let_underscore.rs | 53 + clippy_lints/src/let_with_type_underscore.rs | 44 + clippy_lints/src/lib.rs | 213 ++ .../src/loops/explicit_into_iter_loop.rs | 16 + clippy_lints/src/loops/explicit_iter_loop.rs | 366 ++++ clippy_lints/src/loops/mod.rs | 30 + clippy_lints/src/manual_let_else.rs | 402 ++++ .../src/manual_slice_size_calculation.rs | 78 + .../src/matches/match_like_matches.rs | 39 + clippy_lints/src/matches/mod.rs | 16 + .../src/matches/redundant_pattern_match.rs | 287 +++ clippy_lints/src/methods/drain_collect.rs | 77 + clippy_lints/src/methods/get_unwrap.rs | 80 + clippy_lints/src/methods/iter_nth_zero.rs | 36 + clippy_lints/src/methods/manual_try_fold.rs | 45 + clippy_lints/src/methods/mod.rs | 388 ++++ clippy_lints/src/methods/needless_collect.rs | 20 + .../src/methods/option_map_unwrap_or.rs | 30 + clippy_lints/src/methods/unnecessary_fold.rs | 237 +++ .../src/methods/unnecessary_literal_unwrap.rs | 140 ++ clippy_lints/src/min_ident_chars.rs | 198 ++ clippy_lints/src/misc_early/mod.rs | 57 + clippy_lints/src/missing_fields_in_debug.rs | 269 +++ .../src/mixed_read_write_in_expression.rs | 34 + clippy_lints/src/module_style.rs | 29 + clippy_lints/src/needless_bool.rs | 17 + clippy_lints/src/needless_else.rs | 63 + clippy_lints/src/needless_if.rs | 160 ++ clippy_lints/src/needless_pass_by_value.rs | 16 + clippy_lints/src/non_copy_const.rs | 96 + .../src/operators/arithmetic_side_effects.rs | 33 + clippy_lints/src/operators/float_cmp.rs | 16 + .../src/operators/numeric_arithmetic.rs | 91 + clippy_lints/src/ptr.rs | 17 + clippy_lints/src/question_mark.rs | 81 + clippy_lints/src/raw_strings.rs | 230 +++ clippy_lints/src/redundant_closure_call.rs | 72 + .../src/redundant_type_annotations.rs | 159 ++ clippy_lints/src/regex.rs | 16 + clippy_lints/src/returns.rs | 16 + clippy_lints/src/semicolon_block.rs | 10 + .../src/significant_drop_tightening.rs | 124 ++ clippy_lints/src/single_call_fn.rs | 79 + clippy_lints/src/single_range_in_vec_init.rs | 170 ++ clippy_lints/src/trait_bounds.rs | 58 + .../src/transmute/transmute_ptr_to_ptr.rs | 8 + .../src/transmute/useless_transmute.rs | 8 + clippy_lints/src/tuple_array_conversions.rs | 344 ++++ .../src/undocumented_unsafe_blocks.rs | 115 ++ clippy_lints/src/unnecessary_box_returns.rs | 10 + clippy_lints/src/unused_async.rs | 101 + clippy_lints/src/useless_conversion.rs | 89 + clippy_lints/src/utils/conf.rs | 191 ++ .../almost_standard_lint_formulation.rs | 16 + clippy_lints/src/utils/mod.rs | 21 + clippy_lints/src/vec.rs | 299 +++ clippy_lints/src/visibility.rs | 112 ++ clippy_utils/src/check_proc_macro.rs | 137 ++ clippy_utils/src/consts.rs | 204 ++ clippy_utils/src/eager_or_lazy.rs | 12 + clippy_utils/src/hir_utils.rs | 68 + clippy_utils/src/lib.rs | 67 + clippy_utils/src/msrvs.rs | 37 + clippy_utils/src/qualify_min_const_fn.rs | 212 ++ clippy_utils/src/source.rs | 13 + clippy_utils/src/ty.rs | 20 + rust-toolchain | 44 + src/main.rs | 16 + tests/compile-test.rs | 149 ++ tests/ui-internal/check_formulation.rs | 21 + tests/ui-internal/custom_ice_message.stderr | 10 + tests/ui-toml/bad_toml/conf_bad_toml.stderr | 16 + .../bad_toml_type/conf_bad_type.stderr | 16 + .../conf_deprecated_key.stderr | 32 + .../duplicated_keys/duplicated_keys.stderr | 16 + .../duplicated_keys.stderr | 32 + .../duplicated_keys.stderr | 32 + .../auxiliary/proc_macros.rs | 30 + .../excessive_nesting/excessive_nesting.rs | 168 ++ .../excessive_nesting.stderr | 507 +++++ .../min_ident_chars/min_ident_chars.rs | 18 + .../min_ident_chars/min_ident_chars.stderr | 54 + .../suppress_lint_in_const/test.stderr | 128 ++ .../conf_disallowed_methods.rs | 16 + .../conf_disallowed_methods.stderr | 224 +++ .../toml_unknown_key/conf_unknown_key.stderr | 156 ++ .../auxiliary/proc_macro_unsafe.rs | 17 + .../undocumented_unsafe_blocks/clippy.toml | 15 + .../undocumented_unsafe_blocks.rs | 593 ++++++ .../undocumented_unsafe_blocks.stderr | 592 ++++++ tests/ui-toml/unwrap_used/unwrap_used.stderr | 20 + tests/ui/allow_attributes.fixed | 32 + tests/ui/allow_attributes.rs | 16 + tests/ui/allow_attributes_without_reason.rs | 51 + tests/ui/arc_with_non_send_sync.rs | 21 + tests/ui/arc_with_non_send_sync.stderr | 51 + tests/ui/arithmetic_side_effects.rs | 24 + tests/ui/arithmetic_side_effects.stderr | 1750 +++++++++++++++++ tests/ui/blocks_in_if_conditions_closure.rs | 22 + tests/ui/box_default.fixed | 8 + tests/ui/box_default.rs | 8 + tests/ui/cast.stderr | 42 + tests/ui/clone_on_copy_impl.rs | 16 + tests/ui/collapsible_if.fixed | 15 + tests/ui/collapsible_if.rs | 15 + tests/ui/collapsible_if.stderr | 144 ++ tests/ui/dbg_macro.rs | 42 + tests/ui/dbg_macro.stderr | 188 ++ .../ui/default_constructed_unit_structs.fixed | 36 + tests/ui/default_constructed_unit_structs.rs | 36 + .../default_constructed_unit_structs.stderr | 58 + tests/ui/derive.rs | 24 + tests/ui/diverging_sub_expression.rs | 30 + tests/ui/diverging_sub_expression.stderr | 39 + tests/ui/doc/needless_doctest_main.rs | 31 + tests/ui/drain_collect.fixed | 21 + tests/ui/drain_collect.rs | 64 + tests/ui/drain_collect.stderr | 117 ++ tests/ui/empty_line_after_doc_comments.rs | 12 + tests/ui/empty_line_after_outer_attribute.rs | 12 + tests/ui/endian_bytes.rs | 130 ++ tests/ui/endian_bytes.stderr | 1306 ++++++++++++ tests/ui/eta.fixed | 16 + tests/ui/eta.stderr | 345 ++++ tests/ui/excessive_precision.fixed | 22 + tests/ui/excessive_precision.rs | 22 + tests/ui/explicit_deref_methods.fixed | 53 + tests/ui/explicit_deref_methods.rs | 38 + tests/ui/explicit_deref_methods.stderr | 232 +++ tests/ui/explicit_into_iter_loop.fixed | 76 + tests/ui/explicit_into_iter_loop.rs | 71 + tests/ui/explicit_into_iter_loop.stderr | 60 + tests/ui/explicit_iter_loop.fixed | 66 + tests/ui/explicit_iter_loop.rs | 66 + tests/ui/explicit_iter_loop.stderr | 264 +++ tests/ui/extra_unused_type_parameters.fixed | 16 + tests/ui/extra_unused_type_parameters.rs | 16 + tests/ui/format.fixed | 15 + tests/ui/format.rs | 15 + tests/ui/format.stderr | 240 +++ tests/ui/from_over_into.fixed | 28 + tests/ui/from_over_into.rs | 28 + tests/ui/from_over_into.stderr | 32 + tests/ui/get_unwrap.fixed | 45 + tests/ui/get_unwrap.rs | 45 + tests/ui/get_unwrap.stderr | 57 + tests/ui/if_same_then_else2.stderr | 96 + tests/ui/ifs_same_cond.rs | 22 + .../items_after_test_module/block_module.rs | 29 + .../block_module.stderr | 73 + tests/ui/iter_nth.stderr | 64 + tests/ui/let_underscore_untyped.rs | 16 + tests/ui/let_with_type_underscore.rs | 57 + tests/ui/let_with_type_underscore.stderr | 96 + tests/ui/manual_let_else.rs | 74 + tests/ui/manual_let_else.stderr | 444 +++++ tests/ui/manual_let_else_match.rs | 36 + tests/ui/manual_let_else_match.stderr | 32 + tests/ui/manual_slice_size_calculation.fixed | 71 + tests/ui/manual_slice_size_calculation.rs | 17 + tests/ui/manual_slice_size_calculation.stderr | 111 ++ tests/ui/manual_try_fold.rs | 37 + tests/ui/manual_try_fold.stderr | 54 + tests/ui/map_unwrap_or.rs | 21 + tests/ui/map_unwrap_or.stderr | 22 + tests/ui/match_on_vec_items.rs | 20 + tests/ui/match_same_arms.rs | 63 + tests/ui/match_same_arms2.stderr | 32 + tests/ui/mem_forget.stderr | 86 + tests/ui/min_ident_chars.rs | 98 + tests/ui/min_ident_chars.stderr | 249 +++ .../ui/missing_const_for_fn/cant_be_const.rs | 62 + tests/ui/missing_fields_in_debug.rs | 152 ++ tests/ui/missing_fields_in_debug.stderr | 56 + tests/ui/missing_panics_doc.rs | 42 + tests/ui/missing_panics_doc.stderr | 208 ++ .../needless_arbitrary_self_type_unfixable.rs | 12 + tests/ui/needless_collect.fixed | 21 + tests/ui/needless_collect.rs | 21 + tests/ui/needless_collect_indirect.rs | 15 + tests/ui/needless_else.fixed | 42 + tests/ui/needless_else.rs | 42 + tests/ui/needless_else.stderr | 22 + tests/ui/needless_if.fixed | 192 ++ tests/ui/needless_if.rs | 176 ++ tests/ui/needless_if.stderr | 141 ++ tests/ui/needless_pub_self.fixed | 16 + tests/ui/needless_pub_self.rs | 16 + tests/ui/needless_range_loop.rs | 22 + tests/ui/needless_raw_string.fixed | 34 + tests/ui/needless_raw_string.rs | 34 + tests/ui/needless_raw_string.stderr | 32 + tests/ui/needless_raw_string_hashes.fixed | 38 + tests/ui/needless_raw_string_hashes.rs | 26 + tests/ui/needless_raw_string_hashes.stderr | 88 + tests/ui/needless_return.stderr | 234 +++ tests/ui/never_loop.stderr | 38 + tests/ui/non_minimal_cfg.fixed | 21 + tests/ui/non_minimal_cfg.rs | 21 + tests/ui/nonminimal_bool.stderr | 35 + tests/ui/option_if_let_else.fixed | 16 + tests/ui/option_if_let_else.rs | 16 + tests/ui/option_if_let_else.stderr | 48 + tests/ui/or_fun_call.fixed | 15 + tests/ui/or_fun_call.rs | 15 + tests/ui/or_fun_call.stderr | 560 ++++++ tests/ui/partialeq_to_none.fixed | 16 + tests/ui/partialeq_to_none.rs | 16 + tests/ui/ptr_cast_constness.fixed | 134 ++ tests/ui/ptr_cast_constness.rs | 165 ++ tests/ui/ptr_cast_constness.stderr | 66 + tests/ui/pub_with_shorthand.fixed | 16 + tests/ui/pub_with_shorthand.rs | 16 + tests/ui/pub_without_shorthand.fixed | 16 + tests/ui/pub_without_shorthand.rs | 16 + tests/ui/question_mark.fixed | 21 + tests/ui/question_mark.rs | 21 + tests/ui/redundant_clone.fixed | 22 + tests/ui/redundant_clone.rs | 22 + tests/ui/redundant_clone.stderr | 453 +++++ tests/ui/redundant_closure_call_fixable.fixed | 21 + tests/ui/redundant_closure_call_fixable.rs | 21 + .../ui/redundant_closure_call_fixable.stderr | 22 + ...edundant_pattern_matching_drop_order.fixed | 22 + .../redundant_pattern_matching_drop_order.rs | 22 + .../redundant_pattern_matching_option.fixed | 69 + tests/ui/redundant_pattern_matching_option.rs | 149 ++ .../redundant_pattern_matching_option.stderr | 319 +++ .../redundant_pattern_matching_result.fixed | 69 + tests/ui/redundant_pattern_matching_result.rs | 107 + .../redundant_pattern_matching_result.stderr | 325 +++ tests/ui/redundant_type_annotations.rs | 272 +++ tests/ui/redundant_type_annotations.stderr | 270 +++ tests/ui/regex.rs | 25 + tests/ui/regex.stderr | 284 +++ tests/ui/rename.stderr | 450 +++++ .../ui/same_functions_in_if_condition.stderr | 20 + tests/ui/shadow.rs | 24 + tests/ui/single_call_fn.rs | 64 + tests/ui/single_call_fn.stderr | 113 ++ tests/ui/single_char_add_str.fixed | 20 + tests/ui/single_char_add_str.rs | 20 + tests/ui/single_char_pattern.fixed | 20 + tests/ui/single_char_pattern.rs | 20 + tests/ui/single_match.fixed | 53 + tests/ui/single_match.rs | 78 + tests/ui/single_match.stderr | 57 + tests/ui/single_match_else.fixed | 16 + tests/ui/single_match_else.rs | 106 + tests/ui/single_match_else.stderr | 33 + tests/ui/single_range_in_vec_init.rs | 36 + tests/ui/single_range_in_vec_init.stderr | 160 ++ tests/ui/suspicious_else_formatting.rs | 22 + tests/ui/tuple_array_conversions.rs | 93 + tests/ui/tuple_array_conversions.stderr | 148 ++ tests/ui/undocumented_unsafe_blocks.rs | 42 + tests/ui/undocumented_unsafe_blocks.stderr | 38 + tests/ui/unnecessary_cast.fixed | 124 ++ tests/ui/unnecessary_cast.rs | 124 ++ tests/ui/unnecessary_cast.stderr | 1151 +++++++++++ tests/ui/unnecessary_lazy_eval.fixed | 63 + tests/ui/unnecessary_lazy_eval.rs | 63 + tests/ui/unnecessary_lazy_eval.stderr | 752 +++++++ tests/ui/unnecessary_literal_unwrap.fixed | 119 ++ tests/ui/unnecessary_literal_unwrap.rs | 122 ++ tests/ui/unnecessary_literal_unwrap.stderr | 559 ++++++ .../unnecessary_literal_unwrap_unfixable.rs | 141 ++ ...nnecessary_literal_unwrap_unfixable.stderr | 667 ++++++- .../unnecessary_struct_initialization.fixed | 16 + tests/ui/unnecessary_struct_initialization.rs | 16 + tests/ui/unneeded_wildcard_pattern.fixed | 12 + tests/ui/unneeded_wildcard_pattern.rs | 12 + tests/ui/unneeded_wildcard_pattern.stderr | 224 +++ tests/ui/unnested_or_patterns.fixed | 23 + tests/ui/unnested_or_patterns.rs | 23 + tests/ui/unnested_or_patterns.stderr | 272 +++ tests/ui/unnested_or_patterns2.fixed | 32 + tests/ui/unnested_or_patterns2.rs | 32 + tests/ui/unused_async.rs | 21 + tests/ui/unused_async.stderr | 63 + tests/ui/useless_conversion.stderr | 80 + tests/ui/vec.fixed | 86 +- tests/ui/vec.rs | 70 +- tests/ui/vec.stderr | 274 +++ tests/ui/while_let_on_iterator.fixed | 15 + tests/ui/while_let_on_iterator.rs | 15 + tests/ui/while_let_on_iterator.stderr | 416 ++++ tests/ui/write_literal_2.rs | 16 + tests/ui/write_literal_2.stderr | 16 + util/gh-pages/script.js | 368 ++++ 321 files changed, 34112 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 663b285c8b3d..31b1c59a6c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -71,9 +71,27 @@ If you have any feedback related to the new format, please share it in ## Rust 1.70 +<<<<<<< HEAD +<<<<<<< HEAD Released 2023-06-01 [View all 91 merged pull requests](/~https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-02-26T01%3A05%3A43Z..2023-04-11T13%3A27%3A30Z+base%3Amaster) +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +Current stable, released 2023-06-01 +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +Released 2023-06-01 + +[View all 91 merged pull requests](/~https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-02-26T01%3A05%3A43Z..2023-04-11T13%3A27%3A30Z+base%3Amaster) +<<<<<<< HEAD +>>>>>>> 28655266b (Fix changelog PR listings, create them automatically in `fetch_prs_between.sh`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ### New Lints @@ -131,7 +149,23 @@ Released 2023-06-01 [#10309](/~https://github.com/rust-lang/rust-clippy/pull/10309) * [`items_after_statements`]: `#[allow(items_after_statements)]` now works on items [#10542](/~https://github.com/rust-lang/rust-clippy/pull/10542) +<<<<<<< HEAD +<<<<<<< HEAD +* [`significant_drop_tightening`]: Was optimized +======= +<<<<<<< HEAD +<<<<<<< HEAD * [`significant_drop_tightening`]: Was optimized +======= +* [`significant_drop_tightening`]: was optimized +>>>>>>> 4d9303df1 (Changelog for Rust 1.70 :hammer:) +======= +* [`significant_drop_tightening`]: Was optimized +>>>>>>> 7dd0ae026 (Change changelog typos) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +* [`significant_drop_tightening`]: Was optimized +>>>>>>> 615b25c20 (Rebase attempt number 2) [#10533](/~https://github.com/rust-lang/rust-clippy/pull/10533) ### False Positive Fixes @@ -152,11 +186,38 @@ Released 2023-06-01 [#10527](/~https://github.com/rust-lang/rust-clippy/pull/10527) * [`needless_return`]: No longer lints match statements with incompatible branches [#10593](/~https://github.com/rust-lang/rust-clippy/pull/10593) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) * [`use_self`]: Do not suggest using `Self` in const generic parameters [#10375](/~https://github.com/rust-lang/rust-clippy/pull/10375) * [`mem_replace_option_with_none`]: No longer lints on field expressions [#10594](/~https://github.com/rust-lang/rust-clippy/pull/10594) * [`items_after_statements`]: No longer lints on items from macros +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +* [`use_self`]: do not suggest using `Self` in const generic parameters +======= +* [`use_self`]: Do not suggest using `Self` in const generic parameters +>>>>>>> 7dd0ae026 (Change changelog typos) + [#10375](/~https://github.com/rust-lang/rust-clippy/pull/10375) +* [`mem_replace_option_with_none`]: No longer lints on field expressions + [#10594](/~https://github.com/rust-lang/rust-clippy/pull/10594) +* [`items_after_statements`]: No longer lints on times from macros +>>>>>>> 4d9303df1 (Changelog for Rust 1.70 :hammer:) +======= +>>>>>>> a28eb5995 (Update *Current stable* text in `CHANGELOG.md`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) [#10542](/~https://github.com/rust-lang/rust-clippy/pull/10542) * [`print_literal`], [`write_literal`]: No longer lint strings coming from the `file!()` macro [#10573](/~https://github.com/rust-lang/rust-clippy/pull/10573) @@ -248,7 +309,19 @@ Released 2023-04-20 * [`explicit_auto_deref`]: Now considers projections when determining if auto deref is applicable [#10386](/~https://github.com/rust-lang/rust-clippy/pull/10386) +<<<<<<< HEAD +<<<<<<< HEAD * [`manual_let_else`]: Now considers side effects of branches before linting +======= +<<<<<<< HEAD +* [`manual_let_else`]: Now considers side effects of branches before linting +======= +* [`manual_let_else`]: Now considers side effects of branches before linting +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +* [`manual_let_else`]: Now considers side effects of branches before linting +>>>>>>> 615b25c20 (Rebase attempt number 2) [#10336](/~https://github.com/rust-lang/rust-clippy/pull/10336) * [`uninlined_format_args`]: No longer lints for arguments with generic parameters [#10343](/~https://github.com/rust-lang/rust-clippy/pull/10343) @@ -4820,7 +4893,23 @@ Released 2018-09-13 [`erasing_op`]: https://rust-lang.github.io/rust-clippy/master/index.html#erasing_op [`err_expect`]: https://rust-lang.github.io/rust-clippy/master/index.html#err_expect [`eval_order_dependence`]: https://rust-lang.github.io/rust-clippy/master/index.html#eval_order_dependence +<<<<<<< HEAD +<<<<<<< HEAD +[`excessive_nesting`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting +======= +<<<<<<< HEAD +<<<<<<< HEAD [`excessive_nesting`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting +======= +[`excessive_indentation`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_indentation +>>>>>>> 97c10075e (add the `excessive_*` style lints) +======= +[`excessive_nesting`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting +>>>>>>> e68dbc330 (add `excessive_nesting`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +[`excessive_nesting`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting +>>>>>>> 615b25c20 (Rebase attempt number 2) [`excessive_precision`]: https://rust-lang.github.io/rust-clippy/master/index.html#excessive_precision [`exhaustive_enums`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_enums [`exhaustive_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#exhaustive_structs @@ -4987,7 +5076,23 @@ Released 2018-09-13 [`manual_non_exhaustive`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_non_exhaustive [`manual_ok_or`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ok_or [`manual_range_contains`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_contains +<<<<<<< HEAD +<<<<<<< HEAD +[`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns +======= +<<<<<<< HEAD +<<<<<<< HEAD +[`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns +======= +[`manual_range_pattern`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_pattern +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +======= [`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +[`manual_range_patterns`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_range_patterns +>>>>>>> 615b25c20 (Rebase attempt number 2) [`manual_rem_euclid`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid [`manual_retain`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain [`manual_saturating_arithmetic`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_saturating_arithmetic @@ -5091,7 +5196,22 @@ Released 2018-09-13 [`needless_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_question_mark [`needless_range_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop [`needless_raw_string_hashes`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_string_hashes +<<<<<<< HEAD +<<<<<<< HEAD +[`needless_raw_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_strings +======= +<<<<<<< HEAD +<<<<<<< HEAD +[`needless_raw_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_strings +======= +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= [`needless_raw_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_strings +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +[`needless_raw_strings`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_raw_strings +>>>>>>> 615b25c20 (Rebase attempt number 2) [`needless_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [`needless_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_splitn [`needless_update`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_update @@ -5460,7 +5580,34 @@ Released 2018-09-13 [`allow-private-module-inception`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-private-module-inception [`allowed-idents-below-min-chars`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allowed-idents-below-min-chars [`min-ident-chars-threshold`]: https://doc.rust-lang.org/clippy/lint_configuration.html#min-ident-chars-threshold +<<<<<<< HEAD +<<<<<<< HEAD +[`accept-comment-above-statement`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-statement +[`accept-comment-above-attributes`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-attributes +[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) [`accept-comment-above-statement`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-statement [`accept-comment-above-attributes`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-attributes [`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings +<<<<<<< HEAD +======= +>>>>>>> d5b2f1134 (Now `cargo collect-metadata` updates the `CHANGELOG.md`) +======= +[`accept-comment-above-statement`]: https://doc.rust-lang.org/clippy/lint_configuration.html#accept-comment-above-statement +>>>>>>> d6102018b (Collecting metadata) +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +======= +[`allow-one-hash-in-raw-string`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-string +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +======= +[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/Cargo.toml b/Cargo.toml index 0fb3a3a984b1..4cd77f7740fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,12 +34,33 @@ toml = "0.7.3" walkdir = "2.3" # This is used by the `collect-metadata` alias. filetime = "0.2" +<<<<<<< HEAD +<<<<<<< HEAD itertools = "0.10.1" +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) # UI test dependencies clippy_utils = { path = "clippy_utils" } derive-new = "0.5" if_chain = "1.0" +<<<<<<< HEAD +======= +>>>>>>> 066037b62 (actually, remove rustc-workspace-hack dependency too) +======= +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +itertools = "0.10.1" + +# UI test dependencies +clippy_utils = { path = "clippy_utils" } +derive-new = "0.5" +if_chain = "1.0" +>>>>>>> 0567691cb (This commit resolves issue #10655) quote = "1.0" serde = { version = "1.0.125", features = ["derive"] } syn = { version = "2.0", features = ["full"] } diff --git a/book/src/configuration.md b/book/src/configuration.md index e8274bc4575d..527dd6a1194c 100644 --- a/book/src/configuration.md +++ b/book/src/configuration.md @@ -2,6 +2,16 @@ > **Note:** The configuration file is unstable and may be deprecated in the future. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 194343fce (Explain path-search using a list) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`, which is searched for in: 1. The directory specified by the `CLIPPY_CONF_DIR` environment variable, or @@ -10,6 +20,21 @@ Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml 3. The current directory. It contains a basic `variable = value` mapping e.g. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +Some lints can be configured in a TOML file named `clippy.toml` or `.clippy.toml`, placed in a directory specified by +the environment variable `CLIPPY_CONF_DIR`, or if that's not found, the environment variable +[CARGO_MANIFEST_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html), or if that isn't +found, the current directory. It contains a basic `variable = value` mapping e.g. +>>>>>>> 5f5e2e2ac (Explain which paths clippy searches for configuration in docs) +======= +>>>>>>> 194343fce (Explain path-search using a list) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ```toml avoid-breaking-exported-api = false diff --git a/book/src/development/adding_lints.md b/book/src/development/adding_lints.md index a0db80892502..611edaf26acd 100644 --- a/book/src/development/adding_lints.md +++ b/book/src/development/adding_lints.md @@ -627,6 +627,16 @@ Before submitting your PR make sure you followed all the basic requirements: ## Adding configuration to a lint +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 194343fce (Explain path-search using a list) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Clippy supports the configuration of lints values using a `clippy.toml` file which is searched for in: 1. The directory specified by the `CLIPPY_CONF_DIR` environment variable, or @@ -635,6 +645,21 @@ Clippy supports the configuration of lints values using a `clippy.toml` file whi 3. The current directory. Adding a configuration to a lint can be useful for +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +Clippy supports the configuration of lints values using a `clippy.toml` file in a directory specified by +the environment variable `CLIPPY_CONF_DIR`, or if that's not found, the environment variable +[CARGO_MANIFEST_DIR](https://doc.rust-lang.org/cargo/reference/environment-variables.html), or if that isn't +found, the current directory. Adding a configuration to a lint can be useful for +>>>>>>> 5f5e2e2ac (Explain which paths clippy searches for configuration in docs) +======= +>>>>>>> 194343fce (Explain path-search using a list) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) thresholds or to constrain some behavior that can be seen as a false positive for some users. Adding a configuration is done in the following steps: diff --git a/book/src/development/lint_passes.md b/book/src/development/lint_passes.md index 621fc20972ea..4a49b95479cb 100644 --- a/book/src/development/lint_passes.md +++ b/book/src/development/lint_passes.md @@ -50,7 +50,23 @@ questions already, but the parser is okay with it. This is what we mean when we say `EarlyLintPass` deals with only syntax on the AST level. Alternatively, think of the `foo_functions` lint we mentioned in +<<<<<<< HEAD +<<<<<<< HEAD define new lints chapter. +======= +<<<<<<< HEAD +<<<<<<< HEAD +define new lints chapter. +======= +define new lints chapter. +>>>>>>> d1f55e6b5 (run linkcheck in Remark CI) +======= +define new lints chapter. +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +define new lints chapter. +>>>>>>> 615b25c20 (Rebase attempt number 2) We want the `foo_functions` lint to detect functions with `foo` as their name. Writing a lint that only checks for the name of a function means that we only diff --git a/book/src/lint_configuration.md b/book/src/lint_configuration.md index f8073dac3301..d9d4593c2c4c 100644 --- a/book/src/lint_configuration.md +++ b/book/src/lint_configuration.md @@ -94,7 +94,22 @@ Suppress lints whenever the suggested change would cause breakage for other crat * [`linkedlist`](https://rust-lang.github.io/rust-clippy/master/index.html#linkedlist) * [`rc_mutex`](https://rust-lang.github.io/rust-clippy/master/index.html#rc_mutex) * [`unnecessary_box_returns`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_box_returns) +<<<<<<< HEAD +<<<<<<< HEAD * [`single_call_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#single_call_fn) +======= +<<<<<<< HEAD +<<<<<<< HEAD +* [`single_call_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#single_call_fn) +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +======= +* [`single_call_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#single_call_fn) +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +* [`single_call_fn`](https://rust-lang.github.io/rust-clippy/master/index.html#single_call_fn) +>>>>>>> 615b25c20 (Rebase attempt number 2) ## `msrv` @@ -108,7 +123,22 @@ The minimum rust version that the project supports * [`manual_str_repeat`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_str_repeat) * [`cloned_instead_of_copied`](https://rust-lang.github.io/rust-clippy/master/index.html#cloned_instead_of_copied) * [`redundant_field_names`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names) +<<<<<<< HEAD +<<<<<<< HEAD +* [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or) +======= +<<<<<<< HEAD +<<<<<<< HEAD +* [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or) +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +======= +* [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or) +>>>>>>> bb42b1808 (ran `cargo collect-metadata`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= * [`option_map_unwrap_or`](https://rust-lang.github.io/rust-clippy/master/index.html#option_map_unwrap_or) +>>>>>>> 615b25c20 (Rebase attempt number 2) * [`redundant_static_lifetimes`](https://rust-lang.github.io/rust-clippy/master/index.html#redundant_static_lifetimes) * [`filter_map_next`](https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_next) * [`checked_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#checked_conversions) @@ -148,9 +178,33 @@ The minimum rust version that the project supports * [`manual_is_ascii_check`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check) * [`manual_rem_euclid`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_rem_euclid) * [`manual_retain`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_retain) +<<<<<<< HEAD +<<<<<<< HEAD * [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) * [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions) * [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold) +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +* [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) +* [`tuple_array_conversions`](https://rust-lang.github.io/rust-clippy/master/index.html#tuple_array_conversions) +* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold) +<<<<<<< HEAD +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +======= +* [`type_repetition_in_bounds`](https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds) +>>>>>>> 75f9fbc93 (update lint configuration) +======= +>>>>>>> 826edd75e (heavily refactor) +======= +* [`manual_try_fold`](https://rust-lang.github.io/rust-clippy/master/index.html#manual_try_fold) +>>>>>>> cb5d7e344 (address comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ## `cognitive-complexity-threshold` @@ -163,16 +217,51 @@ The maximum cognitive complexity a function can have * [`cognitive_complexity`](https://rust-lang.github.io/rust-clippy/master/index.html#cognitive_complexity) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +## `excessive-nesting-threshold` +The maximum amount of nesting a block can reside in + +**Default Value:** `0` (`u64`) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= ## `excessive-nesting-threshold` The maximum amount of nesting a block can reside in +<<<<<<< HEAD +**Default Value:** `10` (`u64`) +>>>>>>> 88143ac29 (decided against reinventing the wheel) +======= **Default Value:** `0` (`u64`) +>>>>>>> 725399a17 (move to `complexity` but don't lint by default) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --- **Affected lints:** * [`excessive_nesting`](https://rust-lang.github.io/rust-clippy/master/index.html#excessive_nesting) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ## `disallowed-names` The list of disallowed names to lint about. NB: `bar` is not here since it has legitimate uses. The value `".."` can be used as part of the list to indicate that the configured values should be appended to the @@ -343,17 +432,67 @@ The maximum allowed size for arrays on the stack * [`large_const_arrays`](https://rust-lang.github.io/rust-clippy/master/index.html#large_const_arrays) +<<<<<<< HEAD +<<<<<<< HEAD +## `stack-size-threshold` +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +## `stack-size-threshold` +======= +### stack-size-threshold +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= +## `stack-size-threshold` +>>>>>>> c8c7a3c79 (fix rebase weirdness) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= ## `stack-size-threshold` +>>>>>>> 615b25c20 (Rebase attempt number 2) The maximum allowed stack size for functions in bytes **Default Value:** `512000` (`u64`) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +--- +**Affected lints:** +* [`large_stack_frames`](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames) + + +<<<<<<< HEAD +<<<<<<< HEAD +## `vec-box-size-threshold` +======= +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +## `vec-box-size-threshold` +======= +* [large_stack_frames](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames) +======= --- **Affected lints:** * [`large_stack_frames`](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames) +>>>>>>> 6ad7c6f4e (update lint_configuration.md) +<<<<<<< HEAD +### vec-box-size-threshold +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= +## `vec-box-size-threshold` +>>>>>>> c8c7a3c79 (fix rebase weirdness) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= ## `vec-box-size-threshold` +>>>>>>> 615b25c20 (Rebase attempt number 2) The size of the boxed type in bytes, where boxing in a `Vec` is allowed **Default Value:** `4096` (`u64`) @@ -659,7 +798,87 @@ The maximum byte size a `Future` can have, before it triggers the `clippy::large ## `unnecessary-box-size` +<<<<<<< HEAD +<<<<<<< HEAD +The byte size a `T` in `Box` can have, below which it triggers the `clippy::unnecessary_box` lint + +**Default Value:** `128` (`u64`) + +--- +**Affected lints:** +* [`unnecessary_box_returns`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_box_returns) + + +## `allow-private-module-inception` +Whether to allow module inception if it's not public. + +**Default Value:** `false` (`bool`) + +--- +**Affected lints:** +* [`module_inception`](https://rust-lang.github.io/rust-clippy/master/index.html#module_inception) + + +## `allowed-idents-below-min-chars` +Allowed names below the minimum allowed characters. The value `".."` can be used as part of +the list to indicate, that the configured values should be appended to the default +configuration of Clippy. By default, any configuration will replace the default value. + +**Default Value:** `{"j", "z", "i", "y", "n", "x", "w"}` (`rustc_data_structures::fx::FxHashSet`) + +--- +**Affected lints:** +* [`min_ident_chars`](https://rust-lang.github.io/rust-clippy/master/index.html#min_ident_chars) + + +## `min-ident-chars-threshold` +Minimum chars an ident can have, anything below or equal to this will be linted. + +**Default Value:** `1` (`u64`) + +--- +**Affected lints:** +* [`min_ident_chars`](https://rust-lang.github.io/rust-clippy/master/index.html#min_ident_chars) + + +## `accept-comment-above-statement` +Whether to accept a safety comment to be placed above the statement containing the `unsafe` block + +**Default Value:** `false` (`bool`) + +--- +**Affected lints:** +* [`undocumented_unsafe_blocks`](https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks) + + +## `accept-comment-above-attributes` +Whether to accept a safety comment to be placed above the attributes for the `unsafe` block + +**Default Value:** `false` (`bool`) + +--- +**Affected lints:** +* [`undocumented_unsafe_blocks`](https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks) + + +## `allow-one-hash-in-raw-strings` +Whether to allow `r#""#` when `r""` can be used + +**Default Value:** `false` (`bool`) + +--- +**Affected lints:** +* [`unnecessary_raw_string_hashes`](https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_raw_string_hashes) + +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 203e87518 (`cargo collect-metadata`) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) The byte size a `T` in `Box` can have, below which it triggers the `clippy::unnecessary_box` lint +>>>>>>> 0567691cb (This commit resolves issue #10655) **Default Value:** `128` (`u64`) diff --git a/clippy_dev/src/main.rs b/clippy_dev/src/main.rs index 43eaccdf5a31..af375021b8cb 100644 --- a/clippy_dev/src/main.rs +++ b/clippy_dev/src/main.rs @@ -182,7 +182,33 @@ fn get_clap_config() -> ArgMatches { .long("name") .help("Name of the new lint in snake case, ex: fn_too_long") .required(true) +<<<<<<< HEAD +<<<<<<< HEAD .value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))), +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + .value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))), +======= + .value_parser(|name: &str| { + if name.contains('-') { + Err("Lint name cannot contain `-`, use `_` instead.") + } else { + Ok(name.to_owned()) + } + }), +>>>>>>> a3438da42 (error out if lint name contains dash) +======= + .value_parser(|name: &str| Ok::<_, Infallible>(name.replace("-", "_"))), +>>>>>>> 95b5a7bbe (replace `-` instead of erroring out) +======= + .value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))), +>>>>>>> c70f2a2e5 (apply suggestion) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + .value_parser(|name: &str| Ok::<_, Infallible>(name.replace('-', "_"))), +>>>>>>> 615b25c20 (Rebase attempt number 2) Arg::new("category") .short('c') .long("category") diff --git a/clippy_lints/Cargo.toml b/clippy_lints/Cargo.toml index 11136867ff0a..afffc733dd88 100644 --- a/clippy_lints/Cargo.toml +++ b/clippy_lints/Cargo.toml @@ -21,8 +21,30 @@ regex-syntax = "0.7" serde = { version = "1.0", features = ["derive"] } serde_json = { version = "1.0", optional = true } tempfile = { version = "3.3.0", optional = true } +<<<<<<< HEAD +<<<<<<< HEAD toml = "0.7.3" regex = { version = "1.5", optional = true } +======= +<<<<<<< HEAD +<<<<<<< HEAD +toml = "0.5" +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +toml = "0.7.3" +regex = { version = "1.5", optional = true } +<<<<<<< HEAD +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +toml = "0.7.3" +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= +regex = { version = "1.5", optional = true } +>>>>>>> 7ac15f900 (Add lint to check lint formulation messages) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) unicode-normalization = "0.1" unicode-script = { version = "0.5", default-features = false } semver = "1.0" diff --git a/clippy_lints/src/allow_attributes.rs b/clippy_lints/src/allow_attributes.rs index e1ef514edfd1..189a1b130bd4 100644 --- a/clippy_lints/src/allow_attributes.rs +++ b/clippy_lints/src/allow_attributes.rs @@ -1,6 +1,21 @@ +<<<<<<< HEAD +<<<<<<< HEAD use ast::{AttrStyle, Attribute}; use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::is_from_proc_macro; +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use ast::{AttrStyle, Attribute}; +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::is_from_proc_macro; +<<<<<<< HEAD +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_ast as ast; use rustc_errors::Applicability; use rustc_lint::{LateContext, LateLintPass, LintContext}; @@ -58,7 +73,23 @@ impl LateLintPass<'_> for AllowAttribute { if let AttrStyle::Outer = attr.style; if let Some(ident) = attr.ident(); if ident.name == rustc_span::symbol::sym::allow; +<<<<<<< HEAD +<<<<<<< HEAD + if !is_from_proc_macro(cx, &attr); +======= +<<<<<<< HEAD +<<<<<<< HEAD + if !is_from_proc_macro(cx, &attr); +======= + if !is_from_proc_macro(cx, &(attr, cx)); +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= + if !is_from_proc_macro(cx, &attr); +>>>>>>> 05bfcbd91 (remove tuple) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if !is_from_proc_macro(cx, &attr); +>>>>>>> 615b25c20 (Rebase attempt number 2) then { span_lint_and_sugg( cx, diff --git a/clippy_lints/src/arc_with_non_send_sync.rs b/clippy_lints/src/arc_with_non_send_sync.rs index 7adcd9ad0555..bb5aca45312f 100644 --- a/clippy_lints/src/arc_with_non_send_sync.rs +++ b/clippy_lints/src/arc_with_non_send_sync.rs @@ -2,10 +2,30 @@ use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::last_path_segment; use clippy_utils::ty::{implements_trait, is_type_diagnostic_item}; use rustc_hir::{Expr, ExprKind}; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty; use rustc_middle::ty::print::with_forced_trimmed_paths; use rustc_middle::ty::GenericArgKind; +======= +<<<<<<< HEAD +use rustc_lint::LateContext; +use rustc_lint::LateLintPass; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty; +use rustc_middle::ty::print::with_forced_trimmed_paths; +use rustc_middle::ty::GenericArgKind; +<<<<<<< HEAD +>>>>>>> 75c339cd0 ([`arc_with_non_send_sync`]: look for nested type parameters) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::symbol::sym; @@ -17,10 +37,36 @@ declare_clippy_lint! { /// `Arc` is only `Send`/`Sync` when `T` is [both `Send` and `Sync`](https://doc.rust-lang.org/std/sync/struct.Arc.html#impl-Send-for-Arc%3CT%3E), /// either `T` should be made `Send + Sync` or an `Rc` should be used instead of an `Arc` /// +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + /// ### Example + /// ```rust + /// # use std::cell::RefCell; + /// # use std::sync::Arc; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + /// ### Example. + /// ```rust + /// use std::cell::RefCell; + /// use std::sync::Arc; +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= /// ### Example /// ```rust /// # use std::cell::RefCell; /// # use std::sync::Arc; +>>>>>>> 8330887e1 (Updating documentation and lint formatting.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// fn main() { /// // This is fine, as `i32` implements `Send` and `Sync`. @@ -31,6 +77,19 @@ declare_clippy_lint! { /// let b = Arc::new(RefCell::new(42)); /// } /// ``` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + /// ``` +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= +>>>>>>> 8330887e1 (Updating documentation and lint formatting.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::version = "1.72.0"] pub ARC_WITH_NON_SEND_SYNC, suspicious, @@ -41,14 +100,89 @@ declare_lint_pass!(ArcWithNonSendSync => [ARC_WITH_NON_SEND_SYNC]); impl LateLintPass<'_> for ArcWithNonSendSync { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { let ty = cx.typeck_results().expr_ty(expr); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + if_chain! { + if is_type_diagnostic_item(cx, ty, sym::Arc); + if let ExprKind::Call(func, [arg]) = expr.kind; + if let ExprKind::Path(func_path) = func.kind; + if last_path_segment(&func_path).ident.name == sym::new; + if let arg_ty = cx.typeck_results().expr_ty(arg); +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + if !matches!(arg_ty.kind(), ty::Param(_)); +======= +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= + if match arg_ty.kind() { + ty::Param(_) => false, + _ => true, + }; +>>>>>>> 2f5d1c748 (Adding extra check to ignore generic args.) +======= + if !matches!(arg_ty.kind(), ty::Param(_)); +>>>>>>> 20548eba6 (Swapping to matches macro.) +======= +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if is_type_diagnostic_item(cx, ty, sym::Arc) && let ExprKind::Call(func, [arg]) = expr.kind && let ExprKind::Path(func_path) = func.kind && last_path_segment(&func_path).ident.name == sym::new && let arg_ty = cx.typeck_results().expr_ty(arg) +<<<<<<< HEAD +<<<<<<< HEAD + // make sure that the type is not and does not contain any type parameters + && arg_ty.walk().all(|arg| { + !matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_))) +======= +>>>>>>> 4939a716e (arc_with_non_send_sync: reword and move to suspicious) + // make sure that the type is not and does not contain any type parameters + && arg_ty.walk().all(|arg| { + !matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_))) +<<<<<<< HEAD + }); +>>>>>>> 75c339cd0 ([`arc_with_non_send_sync`]: look for nested type parameters) + if !cx.tcx + .lang_items() + .sync_trait() + .map_or(false, |id| implements_trait(cx, arg_ty, id, &[])) || + !cx.tcx + .get_diagnostic_item(sym::Send) + .map_or(false, |id| implements_trait(cx, arg_ty, id, &[])); + + then { + span_lint_and_help( + cx, + ARC_WITH_NON_SEND_SYNC, + expr.span, + "usage of `Arc` where `T` is not `Send` or `Sync`", + None, + "consider using `Rc` instead or wrapping `T` in a std::sync type like \ +<<<<<<< HEAD +<<<<<<< HEAD + `Mutex`", +======= + Mutex", +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= + `Mutex`", +>>>>>>> 8330887e1 (Updating documentation and lint formatting.) + ); + } +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // make sure that the type is not and does not contain any type parameters && arg_ty.walk().all(|arg| { !matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_))) +>>>>>>> 615b25c20 (Rebase attempt number 2) }) && let Some(send) = cx.tcx.get_diagnostic_item(sym::Send) && let Some(sync) = cx.tcx.lang_items().sync_trait() @@ -73,6 +207,13 @@ impl LateLintPass<'_> for ArcWithNonSendSync { diag.help("consider using an `Rc` instead or wrapping the inner type with a `Mutex`"); } )); +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 4939a716e (arc_with_non_send_sync: reword and move to suspicious) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } diff --git a/clippy_lints/src/assertions_on_constants.rs b/clippy_lints/src/assertions_on_constants.rs index b90914e936a8..98182b69342a 100644 --- a/clippy_lints/src/assertions_on_constants.rs +++ b/clippy_lints/src/assertions_on_constants.rs @@ -39,12 +39,23 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants { Some(sym::assert_macro) => false, _ => return, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else { return; }; let Some(Constant::Bool(val)) = constant(cx, cx.typeck_results(), condition) else { return; }; +<<<<<<< HEAD +======= + let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else { return }; + let Some(Constant::Bool(val)) = constant(cx, cx.typeck_results(), condition) else { return }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if val { span_lint_and_help( cx, diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index 2a5be2756151..ec3f0d5fd1aa 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -363,6 +363,16 @@ declare_clippy_lint! { "ensure that all `cfg(any())` and `cfg(all())` have more than one condition" } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_clippy_lint! { /// ### What it does /// Checks for `#[cfg(features = "...")]` and suggests to replace it with @@ -389,6 +399,17 @@ declare_clippy_lint! { "prevent from misusing the wrong attr name" } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_lint_pass!(Attributes => [ ALLOW_ATTRIBUTES_WITHOUT_REASON, INLINE_ALWAYS, @@ -567,7 +588,23 @@ fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMe } } +<<<<<<< HEAD +<<<<<<< HEAD fn check_lint_reason<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) { +======= +<<<<<<< HEAD +<<<<<<< HEAD +fn check_lint_reason<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) { +======= +fn check_lint_reason(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem], attr: &Attribute) { +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +fn check_lint_reason<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) { +>>>>>>> 05bfcbd91 (remove tuple) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +fn check_lint_reason<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMetaItem], attr: &'cx Attribute) { +>>>>>>> 615b25c20 (Rebase attempt number 2) // Check for the feature if !cx.tcx.features().lint_reasons { return; @@ -582,7 +619,23 @@ fn check_lint_reason<'cx>(cx: &LateContext<'cx>, name: Symbol, items: &[NestedMe } // Check if the attribute is in an external macro and therefore out of the developer's control +<<<<<<< HEAD +<<<<<<< HEAD + if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &attr) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &attr) { +======= + if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &(attr, cx)) { +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= + if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &attr) { +>>>>>>> 05bfcbd91 (remove tuple) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if in_external_macro(cx.sess(), attr.span) || is_from_proc_macro(cx, &attr) { +>>>>>>> 615b25c20 (Rebase attempt number 2) return; } @@ -702,8 +755,29 @@ impl_lint_pass!(EarlyAttributes => [ MISMATCHED_TARGET_OS, EMPTY_LINE_AFTER_OUTER_ATTR, EMPTY_LINE_AFTER_DOC_COMMENTS, +<<<<<<< HEAD +<<<<<<< HEAD NON_MINIMAL_CFG, MAYBE_MISUSED_CFG, +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + NON_MINIMAL_CFG, + MAYBE_MISUSED_CFG, +<<<<<<< HEAD +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= + NON_MINIMAL_CFG, +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= + MAYBE_MISUSED_CFG, +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ]); impl EarlyLintPass for EarlyAttributes { @@ -715,7 +789,22 @@ impl EarlyLintPass for EarlyAttributes { check_deprecated_cfg_attr(cx, attr, &self.msrv); check_mismatched_target_os(cx, attr); check_minimal_cfg_condition(cx, attr); +<<<<<<< HEAD +<<<<<<< HEAD + check_misused_cfg(cx, attr); +======= +<<<<<<< HEAD +<<<<<<< HEAD check_misused_cfg(cx, attr); +======= +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= + check_misused_cfg(cx, attr); +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + check_misused_cfg(cx, attr); +>>>>>>> 615b25c20 (Rebase attempt number 2) } extract_msrv_attr!(EarlyContext); @@ -806,7 +895,23 @@ fn check_deprecated_cfg_attr(cx: &EarlyContext<'_>, attr: &Attribute, msrv: &Msr } fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { +<<<<<<< HEAD +<<<<<<< HEAD + for item in items { +======= +<<<<<<< HEAD +<<<<<<< HEAD for item in items { +======= + for item in items.iter() { +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= + for item in items { +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for item in items { +>>>>>>> 615b25c20 (Rebase attempt number 2) if let NestedMetaItem::MetaItem(meta) = item { if !meta.has_name(sym::any) && !meta.has_name(sym::all) { continue; @@ -825,6 +930,16 @@ fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { } }, ); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> dbc76a766 (Add check for empty cfg `all` condition) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } else if list.is_empty() && meta.has_name(sym::all) { span_lint_and_then( cx, @@ -833,14 +948,45 @@ fn check_nested_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { "unneeded sub `cfg` when there is no condition", |_| {}, ); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= +>>>>>>> dbc76a766 (Add check for empty cfg `all` condition) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } } } +<<<<<<< HEAD +<<<<<<< HEAD +fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { + for item in items { +======= +<<<<<<< HEAD +<<<<<<< HEAD +fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { + for item in items { +======= +fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { +<<<<<<< HEAD + for item in items.iter() { +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +======= + for item in items { +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { for item in items { +>>>>>>> 615b25c20 (Rebase attempt number 2) if let NestedMetaItem::MetaItem(meta) = item { if meta.has_name(sym!(features)) && let Some(val) = meta.value_str() { span_lint_and_sugg( @@ -860,6 +1006,17 @@ fn check_nested_misused_cfg(cx: &EarlyContext<'_>, items: &[NestedMetaItem]) { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn check_minimal_cfg_condition(cx: &EarlyContext<'_>, attr: &Attribute) { if attr.has_name(sym::cfg) && let Some(items) = attr.meta_item_list() @@ -868,6 +1025,16 @@ fn check_minimal_cfg_condition(cx: &EarlyContext<'_>, attr: &Attribute) { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn check_misused_cfg(cx: &EarlyContext<'_>, attr: &Attribute) { if attr.has_name(sym::cfg) && let Some(items) = attr.meta_item_list() @@ -876,6 +1043,17 @@ fn check_misused_cfg(cx: &EarlyContext<'_>, attr: &Attribute) { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> ab66a8681 (Add new `UNIQUE_CFG_CONDITION` lint) +======= +>>>>>>> ad76687b2 (add checking for cfg(features = ...)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) { fn find_os(name: &str) -> Option<&'static str> { UNIX_SYSTEMS diff --git a/clippy_lints/src/bool_assert_comparison.rs b/clippy_lints/src/bool_assert_comparison.rs index adc7e60a3fca..d63684669646 100644 --- a/clippy_lints/src/bool_assert_comparison.rs +++ b/clippy_lints/src/bool_assert_comparison.rs @@ -61,7 +61,15 @@ fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) - ) }) .map_or(false, |assoc_item| { +<<<<<<< HEAD +<<<<<<< HEAD let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_substs_trait(ty, [])); +======= + let proj = Ty::new_projection(cx.tcx,assoc_item.def_id, cx.tcx.mk_substs_trait(ty, [])); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let proj = Ty::new_projection(cx.tcx, assoc_item.def_id, cx.tcx.mk_substs_trait(ty, [])); +>>>>>>> 615b25c20 (Rebase attempt number 2) let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj); nty.is_bool() diff --git a/clippy_lints/src/booleans.rs b/clippy_lints/src/booleans.rs index 04cca9e3177c..218dab521f38 100644 --- a/clippy_lints/src/booleans.rs +++ b/clippy_lints/src/booleans.rs @@ -88,6 +88,40 @@ impl<'tcx> LateLintPass<'tcx> for NonminimalBool { NonminimalBoolVisitor { cx }.visit_body(body); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + +fn is_impl_not_trait_with_bool_out<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool { + cx.tcx + .lang_items() + .not_trait() + .filter(|trait_id| implements_trait(cx, ty, *trait_id, &[])) + .and_then(|trait_id| { + cx.tcx.associated_items(trait_id).find_by_name_and_kind( + cx.tcx, + Ident::from_str("Output"), + ty::AssocKind::Type, + trait_id, + ) + }) + .map_or(false, |assoc_item| { + let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, [])); + let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj); + + nty.is_bool() + }) +} + +>>>>>>> d3534a652 (fix issues 10836) +======= +>>>>>>> e4927f98f (change booleans file and update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) struct NonminimalBoolVisitor<'a, 'tcx> { cx: &'a LateContext<'tcx>, } @@ -472,9 +506,35 @@ impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> { self.bool_expr(e); }, ExprKind::Unary(UnOp::Not, inner) => { +<<<<<<< HEAD +<<<<<<< HEAD + if let ExprKind::Unary(UnOp::Not, ex) = inner.kind && + !self.cx.typeck_results().node_types()[ex.hir_id].is_bool() { + return; +======= +<<<<<<< HEAD +<<<<<<< HEAD + if let ExprKind::Unary(UnOp::Not, ex) = inner.kind && + !self.cx.typeck_results().node_types()[ex.hir_id].is_bool() { + return; +======= + if let ExprKind::Unary(UnOp::Not, ex) = inner.kind { + let ty = self.cx.typeck_results().expr_ty(ex); + if is_impl_not_trait_with_bool_out(self.cx, ty) { + return; + } +>>>>>>> d3534a652 (fix issues 10836) +======= + if let ExprKind::Unary(UnOp::Not, ex) = inner.kind && + !self.cx.typeck_results().node_types()[ex.hir_id].is_bool() { + return; +>>>>>>> e4927f98f (change booleans file and update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if let ExprKind::Unary(UnOp::Not, ex) = inner.kind && !self.cx.typeck_results().node_types()[ex.hir_id].is_bool() { return; +>>>>>>> 615b25c20 (Rebase attempt number 2) } if self.cx.typeck_results().node_types()[inner.hir_id].is_bool() { self.bool_expr(e); diff --git a/clippy_lints/src/casts/borrow_as_ptr.rs b/clippy_lints/src/casts/borrow_as_ptr.rs index b7256dd2eae9..6ae323e826cd 100644 --- a/clippy_lints/src/casts/borrow_as_ptr.rs +++ b/clippy_lints/src/casts/borrow_as_ptr.rs @@ -25,12 +25,34 @@ pub(super) fn check<'tcx>( let mut app = Applicability::MachineApplicable; let snip = snippet_with_context(cx, e.span, cast_expr.span.ctxt(), "..", &mut app).0; // Fix #9884 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 72aa18079 (use rustc's criteria for a temporary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if !e.is_place_expr(|base| { cx.typeck_results() .adjustments() .get(base.hir_id) .is_some_and(|x| x.iter().any(|adj| matches!(adj.kind, Adjust::Deref(_)))) }) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if for_each_unconsumed_temporary(cx, expr, |_| ControlFlow::Break(true)).is_break() { +>>>>>>> d2725402a ([`borrow_as_ptr`]: Ignore temporaries) +======= +>>>>>>> 72aa18079 (use rustc's criteria for a temporary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) return; } diff --git a/clippy_lints/src/casts/cast_possible_wrap.rs b/clippy_lints/src/casts/cast_possible_wrap.rs index ffa571abb391..dcc337fb0b4f 100644 --- a/clippy_lints/src/casts/cast_possible_wrap.rs +++ b/clippy_lints/src/casts/cast_possible_wrap.rs @@ -1,3 +1,16 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +use clippy_utils::diagnostics::span_lint; +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +======= +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::Expr; use rustc_lint::{LateContext, LintContext}; use rustc_middle::ty::Ty; @@ -8,7 +21,22 @@ use super::{utils, CAST_POSSIBLE_WRAP}; const ALLOWED_POINTER_SIZES: [u64; 3] = [16, 32, 64]; // whether the lint should be emitted, and the required pointer size, if it matters +<<<<<<< HEAD +<<<<<<< HEAD #[derive(Copy, Clone, Debug, PartialEq, Eq)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +======= +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +======= +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[derive(Copy, Clone, Debug, PartialEq, Eq)] +>>>>>>> 615b25c20 (Rebase attempt number 2) enum EmitState { NoLint, LintAlways, @@ -25,6 +53,15 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca // and // 2. either: // +<<<<<<< HEAD +======= +<<<<<<< HEAD + // +======= +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // 2a. between two types of constant size that are always the same size // 2b. between one target-dependent size and one constant size integer, // and the constant integer is in the allowed set of target dependent sizes @@ -78,6 +115,16 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca ), }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) cx.struct_span_lint(CAST_POSSIBLE_WRAP, expr.span, message, |diag| { if let EmitState::LintOnPtrSize(16) = should_lint { diag @@ -87,4 +134,16 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_from: Ty<'_>, ca diag } }); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + span_lint(cx, CAST_POSSIBLE_WRAP, expr.span, message.as_str()); +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +======= +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/clippy_lints/src/casts/mod.rs b/clippy_lints/src/casts/mod.rs index 0ac6ef6496a8..25d36cc66abb 100644 --- a/clippy_lints/src/casts/mod.rs +++ b/clippy_lints/src/casts/mod.rs @@ -410,10 +410,36 @@ declare_clippy_lint! { /// let mut_ptr = ptr.cast_mut(); /// let ptr = mut_ptr.cast_const(); /// ``` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 97467e4aa (change `clippy::version` to 1.71.0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::version = "1.71.0"] pub PTR_CAST_CONSTNESS, pedantic, "casting using `as` from and to raw pointers to change constness when specialized methods apply" +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + #[clippy::version = "1.65.0"] + pub PTR_CAST_CONSTNESS, + pedantic, +<<<<<<< HEAD + "TODO" +>>>>>>> 8c191add8 (the implementation!!) +======= + "casting using `as` from and to raw pointers to change constness when specialized methods apply" +>>>>>>> 4ff1cd365 (add description and rename msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } declare_clippy_lint! { @@ -716,7 +742,23 @@ impl<'tcx> LateLintPass<'tcx> for Casts { return; } cast_slice_from_raw_parts::check(cx, expr, cast_expr, cast_to, &self.msrv); +<<<<<<< HEAD +<<<<<<< HEAD + ptr_cast_constness::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv); +======= +<<<<<<< HEAD +<<<<<<< HEAD + ptr_cast_constness::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv); +======= + ptr_cast_constness::check(cx, expr, cast_expr, cast_from, cast_to); +>>>>>>> 8c191add8 (the implementation!!) +======= + ptr_cast_constness::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv); +>>>>>>> c5a914b18 (check msrv) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= ptr_cast_constness::check(cx, expr, cast_expr, cast_from, cast_to, &self.msrv); +>>>>>>> 615b25c20 (Rebase attempt number 2) as_ptr_cast_mut::check(cx, expr, cast_expr, cast_to); fn_to_numeric_cast_any::check(cx, expr, cast_expr, cast_from, cast_to); fn_to_numeric_cast::check(cx, expr, cast_expr, cast_from, cast_to); diff --git a/clippy_lints/src/casts/ptr_cast_constness.rs b/clippy_lints/src/casts/ptr_cast_constness.rs index ce1ab10910cc..35355c9fcb76 100644 --- a/clippy_lints/src/casts/ptr_cast_constness.rs +++ b/clippy_lints/src/casts/ptr_cast_constness.rs @@ -1,6 +1,37 @@ +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::msrvs::{Msrv, POINTER_CAST_CONSTNESS}; use clippy_utils::sugg::Sugg; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 4ff1cd365 (add description and rename msrv tests) +use clippy_utils::msrvs::POINTER_CAST_CONSTNESS; +use clippy_utils::sugg::Sugg; +use clippy_utils::{diagnostics::span_lint_and_sugg, msrvs::Msrv}; +======= +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::sugg::Sugg; +>>>>>>> 8c191add8 (the implementation!!) +======= +use clippy_utils::sugg::Sugg; +use clippy_utils::{diagnostics::span_lint_and_sugg, msrvs::Msrv}; +>>>>>>> c5a914b18 (check msrv) +======= +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::msrvs::{Msrv, POINTER_CAST_CONSTNESS}; +use clippy_utils::sugg::Sugg; +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::msrvs::{Msrv, POINTER_CAST_CONSTNESS}; +use clippy_utils::sugg::Sugg; +>>>>>>> 615b25c20 (Rebase attempt number 2) use if_chain::if_chain; use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; @@ -9,7 +40,40 @@ use rustc_middle::ty::{self, Ty, TypeAndMut}; use super::PTR_CAST_CONSTNESS; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +pub(super) fn check<'tcx>( + cx: &LateContext<'_>, + expr: &Expr<'_>, + cast_expr: &Expr<'_>, + cast_from: Ty<'tcx>, + cast_to: Ty<'tcx>, + msrv: &Msrv, +) { + if_chain! { + if msrv.meets(POINTER_CAST_CONSTNESS); + if let ty::RawPtr(TypeAndMut { mutbl: from_mutbl, ty: from_ty }) = cast_from.kind(); + if let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, ty: to_ty }) = cast_to.kind(); + if matches!((from_mutbl, to_mutbl), + (Mutability::Not, Mutability::Mut) | (Mutability::Mut, Mutability::Not)); + if from_ty == to_ty; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, cast_from: Ty<'_>, cast_to: Ty<'_>) { +======= +pub(super) fn check( +======= pub(super) fn check<'tcx>( +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>, @@ -17,13 +81,30 @@ pub(super) fn check<'tcx>( cast_to: Ty<'tcx>, msrv: &Msrv, ) { +>>>>>>> c5a914b18 (check msrv) if_chain! { if msrv.meets(POINTER_CAST_CONSTNESS); +<<<<<<< HEAD + if let ty::RawPtr(TypeAndMut { mutbl: from_mutbl, .. }) = cast_from.kind(); + if let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, .. }) = cast_to.kind(); +<<<<<<< HEAD + if !matches!((from_mutbl, to_mutbl), + (Mutability::Not, Mutability::Not) | (Mutability::Mut, Mutability::Mut)); +>>>>>>> 8c191add8 (the implementation!!) +======= + if matches!((from_mutbl, to_mutbl), + (Mutability::Not, Mutability::Mut) | (Mutability::Mut, Mutability::Not)); +>>>>>>> f6a0437e7 (Update clippy_lints/src/casts/ptr_cast_constness.rs) +======= if let ty::RawPtr(TypeAndMut { mutbl: from_mutbl, ty: from_ty }) = cast_from.kind(); if let ty::RawPtr(TypeAndMut { mutbl: to_mutbl, ty: to_ty }) = cast_to.kind(); if matches!((from_mutbl, to_mutbl), (Mutability::Not, Mutability::Mut) | (Mutability::Mut, Mutability::Not)); if from_ty == to_ty; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) then { let sugg = Sugg::hir(cx, cast_expr, "_"); let constness = match *to_mutbl { @@ -35,7 +116,23 @@ pub(super) fn check<'tcx>( cx, PTR_CAST_CONSTNESS, expr.span, +<<<<<<< HEAD +<<<<<<< HEAD + "`as` casting between raw pointers while changing only its constness", +======= +<<<<<<< HEAD +<<<<<<< HEAD + "`as` casting between raw pointers while changing only its constness", +======= + "`as` casting between raw pointers while changing its constness", +>>>>>>> 8c191add8 (the implementation!!) +======= + "`as` casting between raw pointers while changing only its constness", +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= "`as` casting between raw pointers while changing only its constness", +>>>>>>> 615b25c20 (Rebase attempt number 2) &format!("try `pointer::cast_{constness}`, a safer alternative"), format!("{}.cast_{constness}()", sugg.maybe_par()), Applicability::MachineApplicable, diff --git a/clippy_lints/src/casts/unnecessary_cast.rs b/clippy_lints/src/casts/unnecessary_cast.rs index ae56f38d9ad5..f2bc5765aade 100644 --- a/clippy_lints/src/casts/unnecessary_cast.rs +++ b/clippy_lints/src/casts/unnecessary_cast.rs @@ -1,12 +1,48 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::numeric_literal::NumericLiteral; use clippy_utils::source::snippet_opt; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::visitors::{for_each_expr, Visitable}; use clippy_utils::{get_parent_expr, get_parent_node, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; use if_chain::if_chain; use rustc_ast::{LitFloatType, LitIntType, LitKind}; use rustc_errors::Applicability; use rustc_hir::def::{DefKind, Res}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::visitors::{for_each_expr, Visitable}; +use clippy_utils::{get_parent_expr, get_parent_node, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; +======= +use clippy_utils::{get_parent_expr, is_ty_alias, path_to_local}; +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +use clippy_utils::{get_parent_expr, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +use if_chain::if_chain; +use rustc_ast::{LitFloatType, LitIntType, LitKind}; +use rustc_errors::Applicability; +<<<<<<< HEAD +use rustc_hir::def::{DefKind, Res}; +======= +use rustc_hir::def::Res; +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use clippy_utils::visitors::{for_each_expr, Visitable}; +use clippy_utils::{get_parent_expr, get_parent_node, is_hir_ty_cfg_dependant, is_ty_alias, path_to_local}; +use if_chain::if_chain; +use rustc_ast::{LitFloatType, LitIntType, LitKind}; +use rustc_errors::Applicability; +use rustc_hir::def::{DefKind, Res}; +<<<<<<< HEAD +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{Expr, ExprKind, Lit, Node, Path, QPath, TyKind, UnOp}; use rustc_lint::{LateContext, LintContext}; use rustc_middle::lint::in_external_macro; @@ -30,10 +66,57 @@ pub(super) fn check<'tcx>( // check both mutability and type are the same if cast_from.kind() == cast_to.kind(); if let ExprKind::Cast(_, cast_to_hir) = expr.kind; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Ignore casts to e.g. type aliases and infer types // - p as pointer_alias // - p as _ if let TyKind::Ptr(to_pointee) = cast_to_hir.kind; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + then { + match to_pointee.ty.kind { + // Ignore casts to pointers that are aliases or cfg dependant, e.g. + // - p as *const std::ffi::c_char (alias) + // - p as *const std::os::raw::c_char (cfg dependant) + TyKind::Path(qpath) => { + if is_ty_alias(&qpath) || is_hir_ty_cfg_dependant(cx, to_pointee.ty) { + return false; + } + }, + // Ignore `p as *const _` + TyKind::Infer => return false, + _ => {}, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + then { + if_chain! { + if let TyKind::Path(qpath) = cast_to_hir.kind; + if is_ty_alias(&qpath); + then { + return false; + } + } + + if let TyKind::Infer = cast_to_hir.kind { + return false; +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= then { match to_pointee.ty.kind { // Ignore casts to pointers that are aliases or cfg dependant, e.g. @@ -47,6 +130,10 @@ pub(super) fn check<'tcx>( // Ignore `p as *const _` TyKind::Infer => return false, _ => {}, +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } span_lint_and_sugg( @@ -61,7 +148,24 @@ pub(super) fn check<'tcx>( } } +<<<<<<< HEAD +<<<<<<< HEAD // skip cast of local that is a type alias +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + // skip cast of local that is a type alias +======= + // skip cast of local to type alias +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + // skip cast of local that is a type alias +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // skip cast of local that is a type alias +>>>>>>> 615b25c20 (Rebase attempt number 2) if let ExprKind::Cast(inner, ..) = expr.kind && let ExprKind::Path(qpath) = inner.kind && let QPath::Resolved(None, Path { res, .. }) = qpath @@ -85,12 +189,34 @@ pub(super) fn check<'tcx>( } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // skip cast of fn call that returns type alias if let ExprKind::Cast(inner, ..) = expr.kind && is_cast_from_ty_alias(cx, inner, cast_from) { return false; } // skip cast to non-primitive type +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // skip non-primitive type cast +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + // skip cast to non-primitive type +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if_chain! { if let ExprKind::Cast(_, cast_to) = expr.kind; if let TyKind::Path(QPath::Resolved(_, path)) = &cast_to.kind; diff --git a/clippy_lints/src/dbg_macro.rs b/clippy_lints/src/dbg_macro.rs index 49452136d6f0..24ba3920b68d 100644 --- a/clippy_lints/src/dbg_macro.rs +++ b/clippy_lints/src/dbg_macro.rs @@ -3,10 +3,36 @@ use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::source::snippet_with_applicability; use clippy_utils::{is_in_cfg_test, is_in_test_function}; use rustc_errors::Applicability; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{Expr, ExprKind, Node}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::{sym, BytePos, Pos, Span}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +use rustc_hir::{Expr, ExprKind, Node, Stmt, StmtKind}; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_span::{sym, Span}; +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= +use rustc_hir::{Expr, ExprKind, Node}; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_span::{sym, BytePos, Pos, Span}; +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_clippy_lint! { /// ### What it does @@ -31,6 +57,16 @@ declare_clippy_lint! { "`dbg!` macro is intended as a debugging tool" } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Gets the span of the statement up to the next semicolon, if and only if the next /// non-whitespace character actually is a semicolon. /// E.g. @@ -54,6 +90,20 @@ fn span_including_semi(cx: &LateContext<'_>, span: Span) -> Option { } else { None } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +fn span_including_semi(cx: &LateContext<'_>, span: Span) -> Span { + let span = cx.sess().source_map().span_extend_to_next_char(span, ';', true); + span.with_hi(span.hi() + rustc_span::BytePos(1)) +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } #[derive(Copy, Clone)] @@ -84,6 +134,16 @@ impl LateLintPass<'_> for DbgMacro { let mut applicability = Applicability::MachineApplicable; let (sugg_span, suggestion) = match expr.peel_drop_temps().kind { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // dbg!() ExprKind::Block(..) => { // If the `dbg!` macro is a "free" statement and not contained within other expressions, @@ -95,6 +155,27 @@ impl LateLintPass<'_> for DbgMacro { } else { (macro_call.span, String::from("()")) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + ExprKind::Block(..) => match cx.tcx.hir().find_parent(expr.hir_id) { + // dbg!() as a standalone statement, suggest removing the whole statement entirely + Some(Node::Stmt( + stmt @ Stmt { + kind: StmtKind::Semi(_), + .. + }, + )) => (span_including_semi(cx, stmt.span.source_callsite()), String::new()), + // empty dbg!() in arbitrary position (e.g. `foo(dbg!())`), suggest replacing with `foo(())` + _ => (macro_call.span, String::from("()")), +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }, // dbg!(1) ExprKind::Match(val, ..) => ( diff --git a/clippy_lints/src/declared_lints.rs b/clippy_lints/src/declared_lints.rs index b2478c4cf786..eb7d0c110e4d 100644 --- a/clippy_lints/src/declared_lints.rs +++ b/clippy_lints/src/declared_lints.rs @@ -141,6 +141,16 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::drop_forget_ref::DROP_NON_DROP_INFO, crate::drop_forget_ref::FORGET_NON_DROP_INFO, crate::drop_forget_ref::MEM_FORGET_INFO, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + crate::drop_forget_ref::UNDROPPED_MANUALLY_DROPS_INFO, +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::duplicate_mod::DUPLICATE_MOD_INFO, crate::else_if_without_else::ELSE_IF_WITHOUT_ELSE_INFO, crate::empty_drop::EMPTY_DROP_INFO, @@ -160,7 +170,24 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::eta_reduction::REDUNDANT_CLOSURE_FOR_METHOD_CALLS_INFO, crate::excessive_bools::FN_PARAMS_EXCESSIVE_BOOLS_INFO, crate::excessive_bools::STRUCT_EXCESSIVE_BOOLS_INFO, +<<<<<<< HEAD +<<<<<<< HEAD crate::excessive_nesting::EXCESSIVE_NESTING_INFO, +======= +<<<<<<< HEAD +<<<<<<< HEAD + crate::excessive_nesting::EXCESSIVE_NESTING_INFO, +======= + crate::excessive_width::EXCESSIVE_INDENTATION_INFO, + crate::excessive_width::EXCESSIVE_WIDTH_INFO, +>>>>>>> 97c10075e (add the `excessive_*` style lints) +======= + crate::excessive_nesting::EXCESSIVE_NESTING_INFO, +>>>>>>> e68dbc330 (add `excessive_nesting`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + crate::excessive_nesting::EXCESSIVE_NESTING_INFO, +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::exhaustive_items::EXHAUSTIVE_ENUMS_INFO, crate::exhaustive_items::EXHAUSTIVE_STRUCTS_INFO, crate::exit::EXIT_INFO, @@ -279,7 +306,30 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::manual_let_else::MANUAL_LET_ELSE_INFO, crate::manual_main_separator_str::MANUAL_MAIN_SEPARATOR_STR_INFO, crate::manual_non_exhaustive::MANUAL_NON_EXHAUSTIVE_INFO, +<<<<<<< HEAD +<<<<<<< HEAD + crate::manual_range_patterns::MANUAL_RANGE_PATTERNS_INFO, +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= + crate::manual_partial_ord_impl::MANUAL_PARTIAL_ORD_IMPL_INFO, +>>>>>>> 2a1fd22f8 (implement `manual_partial_ord_impl`) +======= +>>>>>>> 004e89d4c (rename to `manual_partial_ord_and_ord_impl`) crate::manual_range_patterns::MANUAL_RANGE_PATTERNS_INFO, +======= + crate::manual_range_pattern::MANUAL_RANGE_PATTERN_INFO, +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +======= + crate::manual_range_patterns::MANUAL_RANGE_PATTERNS_INFO, +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + crate::manual_range_patterns::MANUAL_RANGE_PATTERNS_INFO, +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::manual_rem_euclid::MANUAL_REM_EUCLID_INFO, crate::manual_retain::MANUAL_RETAIN_INFO, crate::manual_slice_size_calculation::MANUAL_SLICE_SIZE_CALCULATION_INFO, @@ -547,7 +597,23 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::ranges::RANGE_MINUS_ONE_INFO, crate::ranges::RANGE_PLUS_ONE_INFO, crate::ranges::REVERSED_EMPTY_RANGES_INFO, +<<<<<<< HEAD +<<<<<<< HEAD + crate::raw_strings::NEEDLESS_RAW_STRINGS_INFO, +======= +<<<<<<< HEAD +<<<<<<< HEAD + crate::raw_strings::NEEDLESS_RAW_STRINGS_INFO, +======= + crate::raw_strings::NEEDLESS_RAW_STRING_INFO, +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= crate::raw_strings::NEEDLESS_RAW_STRINGS_INFO, +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + crate::raw_strings::NEEDLESS_RAW_STRINGS_INFO, +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::raw_strings::NEEDLESS_RAW_STRING_HASHES_INFO, crate::rc_clone_in_vec_init::RC_CLONE_IN_VEC_INIT_INFO, crate::read_zero_byte_vec::READ_ZERO_BYTE_VEC_INFO, @@ -579,10 +645,41 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[ crate::shadow::SHADOW_SAME_INFO, crate::shadow::SHADOW_UNRELATED_INFO, crate::significant_drop_tightening::SIGNIFICANT_DROP_TIGHTENING_INFO, +<<<<<<< HEAD +<<<<<<< HEAD + crate::single_call_fn::SINGLE_CALL_FN_INFO, + crate::single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES_INFO, + crate::single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS_INFO, + crate::single_range_in_vec_init::SINGLE_RANGE_IN_VEC_INIT_INFO, +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::single_call_fn::SINGLE_CALL_FN_INFO, crate::single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES_INFO, crate::single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS_INFO, crate::single_range_in_vec_init::SINGLE_RANGE_IN_VEC_INIT_INFO, +<<<<<<< HEAD +======= + crate::single_letter_idents::SINGLE_LETTER_IDENTS_INFO, +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +======= + crate::single_char_idents::SINGLE_CHAR_IDENTS_INFO, +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) + crate::single_char_lifetime_names::SINGLE_CHAR_LIFETIME_NAMES_INFO, + crate::single_component_path_imports::SINGLE_COMPONENT_PATH_IMPORTS_INFO, +>>>>>>> e2ecb132a (rename the lint) +======= + crate::single_range_in_vec_init::SINGLE_RANGE_IN_VEC_INIT_INFO, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) crate::size_of_in_element_count::SIZE_OF_IN_ELEMENT_COUNT_INFO, crate::size_of_ref::SIZE_OF_REF_INFO, crate::slow_vector_initialization::SLOW_VECTOR_INITIALIZATION_INFO, diff --git a/clippy_lints/src/default_constructed_unit_structs.rs b/clippy_lints/src/default_constructed_unit_structs.rs index a294c6937877..b52ad08c88a3 100644 --- a/clippy_lints/src/default_constructed_unit_structs.rs +++ b/clippy_lints/src/default_constructed_unit_structs.rs @@ -1,7 +1,40 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{diagnostics::span_lint_and_sugg, match_def_path, paths}; +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, is_from_proc_macro, match_def_path, paths}; +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, match_def_path, paths}; +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, is_ty_alias, match_def_path, paths}; +>>>>>>> e6dc0efc0 (Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup) +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, is_ty_alias, match_def_path, paths}; +>>>>>>> 8c82486ea ([`default_constructed_unit_structs`]: do not lint type aliases) +use hir::{def::Res, ExprKind}; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::{is_ty_alias, match_def_path, paths}; use hir::def::Res; use hir::ExprKind; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::{LateContext, LateLintPass}; @@ -68,8 +101,27 @@ impl LateLintPass<'_> for DefaultConstructedUnitStructs { if let ty::Adt(def, ..) = cx.typeck_results().expr_ty(expr).kind(); if def.is_struct(); if let var @ ty::VariantDef { ctor: Some((hir::def::CtorKind::Const, _)), .. } = def.non_enum_variant(); +<<<<<<< HEAD +<<<<<<< HEAD if !var.is_field_list_non_exhaustive(); if !expr.span.from_expansion() && !qpath.span().from_expansion(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + if !var.is_field_list_non_exhaustive(); + if !expr.span.from_expansion() && !qpath.span().from_expansion(); +======= + if !var.is_field_list_non_exhaustive() && !is_from_proc_macro(cx, expr); +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= + if !var.is_field_list_non_exhaustive(); + if !expr.span.from_expansion() && !qpath.span().from_expansion(); +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if !var.is_field_list_non_exhaustive(); + if !expr.span.from_expansion() && !qpath.span().from_expansion(); +>>>>>>> 615b25c20 (Rebase attempt number 2) then { span_lint_and_sugg( cx, diff --git a/clippy_lints/src/dereference.rs b/clippy_lints/src/dereference.rs index b2f78ddf9892..59115ae77bfc 100644 --- a/clippy_lints/src/dereference.rs +++ b/clippy_lints/src/dereference.rs @@ -1516,15 +1516,52 @@ fn report<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, state: State, data "&" }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // expr_str (the suggestion) is never shown if is_final_ufcs is true, since it's // `expr.kind == ExprKind::Call`. Therefore, this is, afaik, always unnecessary. /* expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence().order() < PREC_PREFIX { Cow::Owned(format!("({expr_str})")) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + let mut expr_str = if !expr_is_macro_call && is_final_ufcs && expr.precedence().order() < PREC_PREFIX { + format!("({expr_str})") +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } else { expr_str }; */ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + + // Fix #10850, do not lint if it's `Foo::deref` instead of `foo.deref()`. + if is_final_ufcs { + return; + } +======= +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Fix #10850, do not lint if it's `Foo::deref` instead of `foo.deref()`. if is_final_ufcs { diff --git a/clippy_lints/src/derivable_impls.rs b/clippy_lints/src/derivable_impls.rs index 7b0489112e68..6c3a08ac91af 100644 --- a/clippy_lints/src/derivable_impls.rs +++ b/clippy_lints/src/derivable_impls.rs @@ -10,6 +10,22 @@ use rustc_hir::{ use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::ty::adjustment::{Adjust, PointerCoercion}; use rustc_middle::ty::{self, Adt, AdtDef, SubstsRef, Ty, TypeckResults}; +<<<<<<< HEAD +======= +<<<<<<< HEAD +use rustc_middle::ty::adjustment::{Adjust, PointerCoercion}; +use rustc_middle::ty::{self, Adt, AdtDef, SubstsRef, Ty, TypeckResults}; +======= +use rustc_middle::ty::adjustment::{Adjust, PointerCast}; +<<<<<<< HEAD +use rustc_middle::ty::{self, Adt, AdtDef, SubstsRef, TypeckResults}; +>>>>>>> 2ba192695 ([`derivable_impls`]: don't lint if expr unsize-coerces) +======= +use rustc_middle::ty::{self, Adt, AdtDef, SubstsRef, Ty, TypeckResults}; +>>>>>>> 4795c9193 (fix internal lints) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::sym; @@ -76,11 +92,43 @@ fn is_path_self(e: &Expr<'_>) -> bool { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +fn contains_trait_object(ty: Ty<'_>) -> bool { + match ty.kind() { + ty::Ref(_, ty, _) => contains_trait_object(*ty), + ty::Adt(def, substs) => def.is_box() && substs[0].as_type().map_or(false, contains_trait_object), + ty::Dynamic(..) => true, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +fn contains_trait_object(cx: &LateContext<'_>, ty: ty::Ty<'_>) -> bool { +======= +fn contains_trait_object(ty: ty::Ty<'_>) -> bool { +>>>>>>> fcb9a382f (dogfood) + match ty.kind() { + ty::TyKind::Ref(_, ty, _) => contains_trait_object(*ty), + ty::TyKind::Adt(def, substs) => def.is_box() && substs[0].as_type().map_or(false, contains_trait_object), + ty::TyKind::Dynamic(..) => true, +>>>>>>> 2ba192695 ([`derivable_impls`]: don't lint if expr unsize-coerces) +======= fn contains_trait_object(ty: Ty<'_>) -> bool { match ty.kind() { ty::Ref(_, ty, _) => contains_trait_object(*ty), ty::Adt(def, substs) => def.is_box() && substs[0].as_type().map_or(false, contains_trait_object), ty::Dynamic(..) => true, +>>>>>>> 4795c9193 (fix internal lints) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => false, } } @@ -115,14 +163,57 @@ fn check_struct<'tcx>( let is_default_without_adjusts = |expr| { is_default_equivalent(cx, expr) && typeck_results.expr_adjustments(expr).iter().all(|adj| { +<<<<<<< HEAD +<<<<<<< HEAD + !matches!(adj.kind, Adjust::Pointer(PointerCoercion::Unsize) + if contains_trait_object(adj.target)) +======= +<<<<<<< HEAD +<<<<<<< HEAD !matches!(adj.kind, Adjust::Pointer(PointerCoercion::Unsize) if contains_trait_object(adj.target)) +======= + !matches!(adj.kind, Adjust::Pointer(PointerCast::Unsize) +======= + !matches!(adj.kind, Adjust::Pointer(PointerCast::Unsize) +<<<<<<< HEAD +>>>>>>> 5b6ba204a (fmt) + if contains_trait_object(cx, adj.target)) +>>>>>>> 2ba192695 ([`derivable_impls`]: don't lint if expr unsize-coerces) +======= + if contains_trait_object(adj.target)) +>>>>>>> fcb9a382f (dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + !matches!(adj.kind, Adjust::Pointer(PointerCoercion::Unsize) + if contains_trait_object(adj.target)) +>>>>>>> 615b25c20 (Rebase attempt number 2) }) }; let should_emit = match peel_blocks(func_expr).kind { +<<<<<<< HEAD +<<<<<<< HEAD + ExprKind::Tup(fields) => fields.iter().all(is_default_without_adjusts), + ExprKind::Call(callee, args) if is_path_self(callee) => args.iter().all(is_default_without_adjusts), +======= +<<<<<<< HEAD +<<<<<<< HEAD + ExprKind::Tup(fields) => fields.iter().all(is_default_without_adjusts), + ExprKind::Call(callee, args) if is_path_self(callee) => args.iter().all(is_default_without_adjusts), +======= + ExprKind::Tup(fields) => fields.iter().all(|e| is_default_without_adjusts(e)), + ExprKind::Call(callee, args) if is_path_self(callee) => args.iter().all(|e| is_default_without_adjusts(e)), +>>>>>>> 2ba192695 ([`derivable_impls`]: don't lint if expr unsize-coerces) +======= + ExprKind::Tup(fields) => fields.iter().all(is_default_without_adjusts), + ExprKind::Call(callee, args) if is_path_self(callee) => args.iter().all(is_default_without_adjusts), +>>>>>>> fcb9a382f (dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= ExprKind::Tup(fields) => fields.iter().all(is_default_without_adjusts), ExprKind::Call(callee, args) if is_path_self(callee) => args.iter().all(is_default_without_adjusts), +>>>>>>> 615b25c20 (Rebase attempt number 2) ExprKind::Struct(_, fields, _) => fields.iter().all(|ef| is_default_without_adjusts(ef.expr)), _ => false, }; diff --git a/clippy_lints/src/doc.rs b/clippy_lints/src/doc.rs index e5f39d102cd3..f0659b8cbde5 100644 --- a/clippy_lints/src/doc.rs +++ b/clippy_lints/src/doc.rs @@ -921,7 +921,23 @@ impl<'a, 'tcx> Visitor<'tcx> for FindPanicUnwrap<'a, 'tcx> { } } +<<<<<<< HEAD +<<<<<<< HEAD // check for `unwrap` and `expect` for both `Option` and `Result` +======= +<<<<<<< HEAD +<<<<<<< HEAD + // check for `unwrap` and `expect` for both `Option` and `Result` +======= + // check for `unwrap` and `expect` both `Option` and `Result` +>>>>>>> 79f93a655 (missing_panics_doc: pickup expect method) +======= + // check for `unwrap` and `expect` for both `Option` and `Result` +>>>>>>> 73c0c1452 (improve grammer in comment sentence) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // check for `unwrap` and `expect` for both `Option` and `Result` +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Some(arglists) = method_chain_args(expr, &["unwrap"]).or(method_chain_args(expr, &["expect"])) { let receiver_ty = self.typeck_results.expr_ty(arglists[0].0).peel_refs(); if is_type_diagnostic_item(self.cx, receiver_ty, sym::Option) diff --git a/clippy_lints/src/drop_forget_ref.rs b/clippy_lints/src/drop_forget_ref.rs index 14122abbf2c2..3c623704260e 100644 --- a/clippy_lints/src/drop_forget_ref.rs +++ b/clippy_lints/src/drop_forget_ref.rs @@ -66,8 +66,35 @@ declare_clippy_lint! { pub MEM_FORGET, restriction, "`mem::forget` usage on `Drop` types, likely to cause memory leaks" +<<<<<<< HEAD +======= } +<<<<<<< HEAD +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of `std::mem::forget(t)` where `t` is + /// `Drop` or has a field that implements `Drop`. + /// + /// ### Why is this bad? + /// `std::mem::forget(t)` prevents `t` from running its + /// destructor, possibly causing leaks. + /// + /// ### Example + /// ```rust + /// # use std::mem; + /// # use std::rc::Rc; + /// mem::forget(Rc::new(55)) + /// ``` + #[clippy::version = "pre 1.29.0"] + pub MEM_FORGET, + restriction, + "`mem::forget` usage on `Drop` types, likely to cause memory leaks" +>>>>>>> 0567691cb (This commit resolves issue #10655) +} + +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) const DROP_NON_DROP_SUMMARY: &str = "call to `std::mem::drop` with a value that does not implement `Drop`. \ Dropping such a type only extends its contained lifetimes"; const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value that does not implement `Drop`. \ @@ -76,6 +103,16 @@ const FORGET_NON_DROP_SUMMARY: &str = "call to `std::mem::forget` with a value t declare_lint_pass!(DropForgetRef => [ DROP_NON_DROP, FORGET_NON_DROP, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + UNDROPPED_MANUALLY_DROPS, +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) MEM_FORGET, ]); @@ -103,6 +140,14 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { || drop_is_single_call_in_arm ) => { +<<<<<<< HEAD +<<<<<<< HEAD + (DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into(), Some(arg.span)) +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) (DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into(), Some(arg.span)) }, sym::mem_forget => { @@ -121,6 +166,41 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { ) } else { (FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into(), Some(arg.span)) +<<<<<<< HEAD +======= + (DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into()) +======= + (DROP_NON_DROP, DROP_NON_DROP_SUMMARY.into(), Some(arg.span)) +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) + }, + sym::mem_forget => { + if arg_ty.needs_drop(cx.tcx, cx.param_env) { + ( + MEM_FORGET, + Cow::Owned(format!( + "usage of `mem::forget` on {}", + if arg_ty.ty_adt_def().map_or(false, |def| def.has_dtor(cx.tcx)) { + "`Drop` type" + } else { + "type with `Drop` fields" + } + )), + None, + ) + } else { +<<<<<<< HEAD + (FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into(), Some(arg.span)) +======= +<<<<<<< HEAD + (FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into()) +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= + (FORGET_NON_DROP, FORGET_NON_DROP_SUMMARY.into(), Some(arg.span)) +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } _ => return, @@ -130,7 +210,23 @@ impl<'tcx> LateLintPass<'tcx> for DropForgetRef { lint, expr.span, &msg, +<<<<<<< HEAD +<<<<<<< HEAD + note_span, +======= +<<<<<<< HEAD +<<<<<<< HEAD + note_span, +======= + Some(arg.span), +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= + note_span, +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= note_span, +>>>>>>> 615b25c20 (Rebase attempt number 2) &format!("argument has type `{arg_ty}`"), ); } diff --git a/clippy_lints/src/endian_bytes.rs b/clippy_lints/src/endian_bytes.rs index dda14b4df533..b2ec4cff05a6 100644 --- a/clippy_lints/src/endian_bytes.rs +++ b/clippy_lints/src/endian_bytes.rs @@ -1,10 +1,33 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use crate::Lint; use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_lint_allowed; use rustc_hir::{Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass, LintContext}; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_middle::lint::in_external_macro; use rustc_middle::ty::Ty; +======= +<<<<<<< HEAD +use rustc_middle::{lint::in_external_macro, ty::Ty}; +<<<<<<< HEAD +======= +use rustc_middle::lint::in_external_macro; +use rustc_middle::ty::Ty; +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_middle::lint::in_external_macro; +use rustc_middle::ty::Ty; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::Symbol; use std::borrow::Cow; @@ -12,6 +35,38 @@ use std::borrow::Cow; declare_clippy_lint! { /// ### What it does /// Checks for the usage of the `to_ne_bytes` method and/or the function `from_ne_bytes`. +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +use clippy_utils::{ + diagnostics::{span_lint_and_help, span_lint_and_then}, + is_lint_allowed, match_def_path, path_def_id, +}; +======= +use crate::Lint; +use clippy_utils::{diagnostics::span_lint_and_then, is_lint_allowed}; +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +use rustc_hir::{Expr, ExprKind}; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_middle::lint::in_external_macro; +======= +>>>>>>> 04b7cae37 (refine output) +use rustc_session::{declare_lint_pass, declare_tool_lint}; +use rustc_span::Symbol; +use std::borrow::Cow; + +declare_clippy_lint! { + /// ### What it does +<<<<<<< HEAD + /// Checks for the usage of the `to_ne_bytes` method. +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= + /// Checks for the usage of the `to_ne_bytes` method and/or the function `from_ne_bytes`. +>>>>>>> 95e8c0b35 (don't allocate the names) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Why is this bad? /// It's not, but some may prefer to specify the target endianness explicitly. @@ -22,6 +77,14 @@ declare_clippy_lint! { /// let _y = 2i64.to_ne_bytes(); /// ``` #[clippy::version = "1.71.0"] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) pub HOST_ENDIAN_BYTES, restriction, "disallows usage of the `to_ne_bytes` method" @@ -30,6 +93,54 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does /// Checks for the usage of the `to_le_bytes` method and/or the function `from_le_bytes`. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + /// + /// ### Why is this bad? + /// It's not, but some may wish to lint usage of this method, either to suggest using the host + /// endianness or big endian. + /// + /// ### Example + /// ```rust,ignore + /// let _x = 2i32.to_le_bytes(); + /// let _y = 2i64.to_le_bytes(); + /// ``` + #[clippy::version = "1.71.0"] +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) + pub LITTLE_ENDIAN_BYTES, +======= + pub HOST_ENDIAN_BYTES, +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) + restriction, + "disallows usage of the `to_ne_bytes` method" +} + +declare_clippy_lint! { + /// ### What it does +<<<<<<< HEAD + /// Checks for the usage of the `to_be_bytes` method and/or the function `from_be_bytes`. + /// + /// ### Why is this bad? + /// It's not, but some may wish to lint usage of this method, either to suggest using the host + /// endianness or little endian. + /// + /// ### Example + /// ```rust,ignore + /// let _x = 2i32.to_be_bytes(); + /// let _y = 2i64.to_be_bytes(); +======= + /// Checks for the usage of the `to_le_bytes` method. +======= +>>>>>>> 95e8c0b35 (don't allocate the names) /// /// ### Why is this bad? /// It's not, but some may wish to lint usage of this method, either to suggest using the host @@ -37,10 +148,17 @@ declare_clippy_lint! { /// /// ### Example /// ```rust,ignore +<<<<<<< HEAD + /// // example code where clippy issues a warning +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= /// let _x = 2i32.to_le_bytes(); /// let _y = 2i64.to_le_bytes(); /// ``` #[clippy::version = "1.71.0"] +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) pub LITTLE_ENDIAN_BYTES, restriction, "disallows usage of the `to_le_bytes` method" @@ -58,6 +176,13 @@ declare_clippy_lint! { /// ```rust,ignore /// let _x = 2i32.to_be_bytes(); /// let _y = 2i64.to_be_bytes(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` #[clippy::version = "1.71.0"] pub BIG_ENDIAN_BYTES, @@ -67,10 +192,32 @@ declare_clippy_lint! { declare_lint_pass!(EndianBytes => [HOST_ENDIAN_BYTES, LITTLE_ENDIAN_BYTES, BIG_ENDIAN_BYTES]); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 95e8c0b35 (don't allocate the names) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) const HOST_NAMES: [&str; 2] = ["from_ne_bytes", "to_ne_bytes"]; const LITTLE_NAMES: [&str; 2] = ["from_le_bytes", "to_le_bytes"]; const BIG_NAMES: [&str; 2] = ["from_be_bytes", "to_be_bytes"]; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= +>>>>>>> 95e8c0b35 (don't allocate the names) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Clone, Debug)] enum LintKind { Host, @@ -78,12 +225,39 @@ enum LintKind { Big, } +<<<<<<< HEAD +<<<<<<< HEAD +#[derive(Clone, Copy, PartialEq)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD #[derive(Clone, Copy, PartialEq)] +======= +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +======= +#[derive(Clone, Copy, PartialEq)] +>>>>>>> 7fe200ed0 (derive Copy/PartialEq for `Prefix`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[derive(Clone, Copy, PartialEq)] +>>>>>>> 615b25c20 (Rebase attempt number 2) enum Prefix { From, To, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl LintKind { fn allowed(&self, cx: &LateContext<'_>, expr: &Expr<'_>) -> bool { is_lint_allowed(cx, self.as_lint(), expr.hir_id) @@ -97,17 +271,85 @@ impl LintKind { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + fn as_name(&self, prefix: Prefix) -> &str { + let index = usize::from(prefix == Prefix::To); + + match self { + LintKind::Host => HOST_NAMES[index], + LintKind::Little => LITTLE_NAMES[index], + LintKind::Big => BIG_NAMES[index], +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + fn to_name(&self, prefix: &str) -> String { + match self { + LintKind::Host => format!("{prefix}_ne_bytes"), + LintKind::Little => format!("{prefix}_le_bytes"), + LintKind::Big => format!("{prefix}_be_bytes"), +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= + fn to_name(&self, prefix: &str) -> &str { + match self { + LintKind::Host => { + if prefix == "from" { + HOST_NAMES[0] + } else { + HOST_NAMES[1] + } + }, + LintKind::Little => { + if prefix == "from" { + LITTLE_NAMES[0] + } else { + LITTLE_NAMES[1] + } + }, + LintKind::Big => { + if prefix == "from" { + BIG_NAMES[0] + } else { + BIG_NAMES[1] + } + }, +>>>>>>> 95e8c0b35 (don't allocate the names) +======= + fn as_name(&self, prefix: &Prefix) -> &str { + let index = usize::from(matches!(prefix, Prefix::To)); +======= fn as_name(&self, prefix: Prefix) -> &str { let index = usize::from(prefix == Prefix::To); +>>>>>>> 7fe200ed0 (derive Copy/PartialEq for `Prefix`) match self { LintKind::Host => HOST_NAMES[index], LintKind::Little => LITTLE_NAMES[index], LintKind::Big => BIG_NAMES[index], +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl LateLintPass<'_> for EndianBytes { fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { if in_external_macro(cx.sess(), expr.span) { @@ -121,10 +363,99 @@ impl LateLintPass<'_> for EndianBytes { if ty.is_primitive_ty(); if maybe_lint_endian_bytes(cx, expr, Prefix::To, method_name.ident.name, ty); then { +<<<<<<< HEAD +<<<<<<< HEAD return; } } +======= +======= +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +impl LateLintPass<'_> for EndianBytes { + fn check_expr(&mut self, cx: &LateContext<'_>, expr: &Expr<'_>) { + if in_external_macro(cx.sess(), expr.span) { + return; + } + + if_chain! { + if let ExprKind::MethodCall(method_name, receiver, args, ..) = expr.kind; + if args.is_empty(); + let ty = cx.typeck_results().expr_ty(receiver); + if ty.is_primitive_ty(); + if maybe_lint_endian_bytes(cx, expr, Prefix::To, method_name.ident.name, ty); + then { +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + if method_name.ident.name == sym!(to_ne_bytes) { + span_lint_and_help( + cx, + HOST_ENDIAN_BYTES, + expr.span, + "use of the method `to_ne_bytes`", + None, + "consider specifying the desired endianness", + ); + } else if method_name.ident.name == sym!(to_le_bytes) { + span_lint_and_then(cx, LITTLE_ENDIAN_BYTES, expr.span, "use of the method `to_le_bytes`", |diag| { + if is_lint_allowed(cx, BIG_ENDIAN_BYTES, expr.hir_id) { + diag.help("use `to_be_bytes` instead"); + } + }); + } else if method_name.ident.name == sym!(to_be_bytes) { + span_lint_and_then(cx, BIG_ENDIAN_BYTES, expr.span, "use of the method `to_be_bytes`", |diag| { + if is_lint_allowed(cx, LITTLE_ENDIAN_BYTES, expr.hir_id) { + diag.help("use `to_le_bytes` instead"); + } + }); + } + + // don't waste time also checking from_**_bytes +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + return; + } + } + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + if_chain! { + if let ExprKind::Call(function, ..) = expr.kind; + if let ExprKind::Path(qpath) = function.kind; + if let Some(def_id) = cx.qpath_res(&qpath, function.hir_id).opt_def_id(); + if let Some(function_name) = cx.get_def_path(def_id).last(); + let ty = cx.typeck_results().expr_ty(expr); + if ty.is_primitive_ty(); + then { +<<<<<<< HEAD +<<<<<<< HEAD + maybe_lint_endian_bytes(cx, expr, Prefix::From, *function_name, ty); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + maybe_lint_endian_bytes(cx, expr, Prefix::From, *function_name, ty); +======= + span_lint_and_help( + cx, + HOST_ENDIAN_BYTES, + expr.span, + "use of the method `from_ne_bytes`", + None, + &format!("consider specifying the desired endianness: {expr:?}"), + ); + +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) if_chain! { if let ExprKind::Call(function, ..) = expr.kind; if let ExprKind::Path(qpath) = function.kind; @@ -133,16 +464,100 @@ impl LateLintPass<'_> for EndianBytes { let ty = cx.typeck_results().expr_ty(expr); if ty.is_primitive_ty(); then { +<<<<<<< HEAD +<<<<<<< HEAD + if match_def_path(cx, function_def_id, &["from_ne_bytes"]) { + span_lint_and_help( + cx, + HOST_ENDIAN_BYTES, + expr.span, + "use of the method `from_ne_bytes`", + None, + "consider specifying the desired endianness", + ); + } else if match_def_path(cx, function_def_id, &["from_le_bytes"]) { + span_lint_and_then(cx, LITTLE_ENDIAN_BYTES, expr.span, "use of the method `from_le_bytes`", |diag| { + if is_lint_allowed(cx, BIG_ENDIAN_BYTES, expr.hir_id) { + diag.help("use `from_be_bytes` instead"); + } + }); + } else if match_def_path(cx, function_def_id, &["from_be_bytes"]) { + span_lint_and_then(cx, BIG_ENDIAN_BYTES, expr.span, "use of the method `from_be_bytes`", |diag| { + if is_lint_allowed(cx, LITTLE_ENDIAN_BYTES, expr.hir_id) { + diag.help("use `from_le_bytes` instead"); + } + }); + } +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= + try_lint_endian_bytes(cx, expr, "from", *function_name); +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= + try_lint_endian_bytes(cx, expr, "from", *function_name, ty); +>>>>>>> 04b7cae37 (refine output) +======= + maybe_lint_endian_bytes(cx, expr, "from", *function_name, ty); +>>>>>>> 95e8c0b35 (don't allocate the names) +======= + maybe_lint_endian_bytes(cx, expr, &Prefix::From, *function_name, ty); +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +======= maybe_lint_endian_bytes(cx, expr, Prefix::From, *function_name, ty); +>>>>>>> 7fe200ed0 (derive Copy/PartialEq for `Prefix`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + maybe_lint_endian_bytes(cx, expr, Prefix::From, *function_name, ty); +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } } +<<<<<<< HEAD +<<<<<<< HEAD + +======= +<<<<<<< HEAD +<<<<<<< HEAD + +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix, name: Symbol, ty: Ty<'_>) -> bool { let ne = LintKind::Host.as_name(prefix); let le = LintKind::Little.as_name(prefix); let be = LintKind::Big.as_name(prefix); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + +<<<<<<< HEAD +fn try_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: &str, name: Symbol, ty: Ty<'_>) -> bool { + let ne = format!("{prefix}_ne_bytes"); + let le = format!("{prefix}_le_bytes"); + let be = format!("{prefix}_be_bytes"); +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= +fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: &str, name: Symbol, ty: Ty<'_>) -> bool { + let ne = LintKind::Host.to_name(prefix); + let le = LintKind::Little.to_name(prefix); + let be = LintKind::Big.to_name(prefix); +>>>>>>> 95e8c0b35 (don't allocate the names) +======= +fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: &Prefix, name: Symbol, ty: Ty<'_>) -> bool { +======= +fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix, name: Symbol, ty: Ty<'_>) -> bool { +>>>>>>> 7fe200ed0 (derive Copy/PartialEq for `Prefix`) + let ne = LintKind::Host.as_name(prefix); + let le = LintKind::Little.as_name(prefix); + let be = LintKind::Big.as_name(prefix); +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let (lint, other_lints) = match name.as_str() { name if name == ne => ((&LintKind::Host), [(&LintKind::Little), (&LintKind::Big)]), @@ -164,14 +579,46 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix } // ne_bytes and all other lints allowed +<<<<<<< HEAD +<<<<<<< HEAD + if lint.as_name(prefix) == ne && other_lints.iter().all(|lint| lint.allowed(cx, expr)) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + if lint.as_name(prefix) == ne && other_lints.iter().all(|lint| lint.allowed(cx, expr)) { +======= + if lint.to_name(prefix) == ne && other_lints.iter().all(|lint| lint.allowed(cx, expr)) { +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= if lint.as_name(prefix) == ne && other_lints.iter().all(|lint| lint.allowed(cx, expr)) { +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if lint.as_name(prefix) == ne && other_lints.iter().all(|lint| lint.allowed(cx, expr)) { +>>>>>>> 615b25c20 (Rebase attempt number 2) help = Some(Cow::Borrowed("specify the desired endianness explicitly")); break 'build_help; } // le_bytes where ne_bytes allowed but be_bytes is not, or le_bytes where ne_bytes allowed but // le_bytes is not +<<<<<<< HEAD +<<<<<<< HEAD + if (lint.as_name(prefix) == le || lint.as_name(prefix) == be) && LintKind::Host.allowed(cx, expr) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + if (lint.as_name(prefix) == le || lint.as_name(prefix) == be) && LintKind::Host.allowed(cx, expr) { +======= + if (lint.to_name(prefix) == le || lint.to_name(prefix) == be) && LintKind::Host.allowed(cx, expr) { +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= + if (lint.as_name(prefix) == le || lint.as_name(prefix) == be) && LintKind::Host.allowed(cx, expr) { +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if (lint.as_name(prefix) == le || lint.as_name(prefix) == be) && LintKind::Host.allowed(cx, expr) { +>>>>>>> 615b25c20 (Rebase attempt number 2) help = Some(Cow::Borrowed("use the native endianness instead")); break 'build_help; } @@ -187,7 +634,27 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix help_str.push_str("either of "); } +<<<<<<< HEAD +<<<<<<< HEAD + help_str.push_str(&format!("`{ty}::{}` ", lint.as_name(prefix))); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + help_str.push_str(&format!("`{ty}::{}` ", lint.as_name(prefix))); +======= + help_str.push_str(&format!("`{}` ", lint.to_name(prefix))); +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= + help_str.push_str(&format!("`{ty}::{}` ", lint.to_name(prefix))); +>>>>>>> 04b7cae37 (refine output) +======= + help_str.push_str(&format!("`{ty}::{}` ", lint.as_name(prefix))); +>>>>>>> a6c36556c (use enum for `prefix` instead of `&str`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= help_str.push_str(&format!("`{ty}::{}` ", lint.as_name(prefix))); +>>>>>>> 615b25c20 (Rebase attempt number 2) if i != len && !only_one { help_str.push_str("or "); @@ -201,12 +668,37 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix cx, lint.as_lint(), expr.span, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + &format!( + "usage of the {}`{ty}::{}`{}", + if prefix == Prefix::From { "function " } else { "" }, + lint.as_name(prefix), + if prefix == Prefix::To { " method" } else { "" }, + ), +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + &format!("usage of the method `{}`", lint.to_name(prefix)), +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= &format!( "usage of the {}`{ty}::{}`{}", if prefix == Prefix::From { "function " } else { "" }, lint.as_name(prefix), if prefix == Prefix::To { " method" } else { "" }, ), +>>>>>>> 04b7cae37 (refine output) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) move |diag| { if let Some(help) = help { diag.help(help); @@ -216,3 +708,14 @@ fn maybe_lint_endian_bytes(cx: &LateContext<'_>, expr: &Expr<'_>, prefix: Prefix true } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/clippy_lints/src/excessive_nesting.rs b/clippy_lints/src/excessive_nesting.rs index 8911f1872c2c..99a495ebeefb 100644 --- a/clippy_lints/src/excessive_nesting.rs +++ b/clippy_lints/src/excessive_nesting.rs @@ -1,12 +1,62 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5da34559e (Check if from proc macro and better tests) +use clippy_utils::{diagnostics::span_lint_and_help, source::snippet}; +use rustc_ast::{ + node_id::NodeSet, + visit::{walk_block, walk_item, Visitor}, + Block, Crate, Inline, Item, ItemKind, ModKind, NodeId, +======= +use clippy_utils::diagnostics::span_lint_and_help; +use rustc_ast::{ +<<<<<<< HEAD +<<<<<<< HEAD + node_id::NodeId, + ptr::P, + visit::{FnKind, Visitor}, + Arm, AssocItemKind, Block, Expr, ExprKind, Inline, Item, ItemKind, Local, LocalKind, ModKind, ModSpans, Pat, + PatKind, Stmt, StmtKind, +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + visit::{walk_block, walk_item, Visitor}, + Block, Crate, Inline, Item, ItemKind, ModKind, +>>>>>>> 88143ac29 (decided against reinventing the wheel) +======= + node_id::NodeSet, + visit::{walk_block, walk_item, Visitor}, + Block, Crate, Inline, Item, ItemKind, ModKind, NodeId, +>>>>>>> 378d77584 (work with lint attributes) +}; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; use rustc_ast::node_id::NodeSet; use rustc_ast::visit::{walk_block, walk_item, Visitor}; use rustc_ast::{Block, Crate, Inline, Item, ItemKind, ModKind, NodeId}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD declare_clippy_lint! { /// ### What it does @@ -16,15 +66,66 @@ declare_clippy_lint! { /// /// ### Why is this bad? /// It can severely hinder readability. +======= +use thin_vec::ThinVec; +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + +declare_clippy_lint! { + /// ### What it does + /// Checks for blocks which are nested beyond a certain threshold. + /// + /// Note: Even though this lint is warn-by-default, it will only trigger if a maximum nesting level is defined in the clippy.toml file. /// + /// ### Why is this bad? + /// It can severely hinder readability. + /// +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + /// ### Known issues + /// + /// Nested inline modules will all be linted, rather than just the outermost one + /// that applies. This makes the output a bit verbose. +>>>>>>> e68dbc330 (add `excessive_nesting`) + /// +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ### Example /// An example clippy.toml configuration: /// ```toml /// # clippy.toml /// excessive-nesting-threshold = 3 /// ``` +<<<<<<< HEAD +<<<<<<< HEAD /// ```rust,ignore /// // lib.rs +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// ```rust,ignore + /// // lib.rs +======= + /// lib.rs: + /// ```rust,ignore +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + /// ```rust,ignore + /// // lib.rs +>>>>>>> b7fedb88c (Update excessive_nesting.rs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// ```rust,ignore + /// // lib.rs +>>>>>>> 615b25c20 (Rebase attempt number 2) /// pub mod a { /// pub struct X; /// impl X { @@ -35,10 +136,35 @@ declare_clippy_lint! { /// } /// } /// } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` /// Use instead: /// ```rust,ignore /// // a.rs +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= + /// ``` +>>>>>>> b7fedb88c (Update excessive_nesting.rs) + /// Use instead: + /// ```rust,ignore +<<<<<<< HEAD +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + /// // a.rs +>>>>>>> b7fedb88c (Update excessive_nesting.rs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// fn private_run(x: &X) { /// if true { /// // etc... @@ -52,17 +178,66 @@ declare_clippy_lint! { /// } /// } /// ``` +<<<<<<< HEAD +<<<<<<< HEAD + /// ```rust,ignore + /// // lib.rs +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD /// ```rust,ignore /// // lib.rs +======= + /// ```rust,ignore +<<<<<<< HEAD + /// lib// .rs +>>>>>>> b7fedb88c (Update excessive_nesting.rs) +======= + /// // lib.rs +>>>>>>> d1957b87c (Update excessive_nesting.rs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// ```rust,ignore + /// // lib.rs +>>>>>>> 615b25c20 (Rebase attempt number 2) /// pub mod a; /// ``` #[clippy::version = "1.70.0"] pub EXCESSIVE_NESTING, complexity, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +======= + /// lib.rs: + /// ```rust,ignore + /// pub mod a; + /// ``` +>>>>>>> 378d77584 (work with lint attributes) + #[clippy::version = "1.70.0"] + pub EXCESSIVE_NESTING, + restriction, +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +>>>>>>> 725399a17 (move to `complexity` but don't lint by default) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "checks for blocks nested beyond a certain threshold" } impl_lint_pass!(ExcessiveNesting => [EXCESSIVE_NESTING]); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Clone)] pub struct ExcessiveNesting { pub excessive_nesting_threshold: u64, @@ -90,6 +265,62 @@ impl EarlyLintPass for ExcessiveNesting { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let mut visitor = NestingVisitor { + conf: self, + cx, + nest_level: 0, + }; + + for item in &krate.items { + visitor.visit_item(item); + } + } + + fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) { + self.check_node_id(cx, block.span, block.id); + } + + fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { + self.check_node_id(cx, item.span, item.id); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +#[derive(Clone, Copy)] +======= +#[derive(Clone)] +>>>>>>> 378d77584 (work with lint attributes) +pub struct ExcessiveNesting { + pub excessive_nesting_threshold: u64, + pub nodes: NodeSet, +} + +impl ExcessiveNesting { + pub fn check_node_id(&self, cx: &EarlyContext<'_>, span: Span, node_id: NodeId) { + if self.nodes.contains(&node_id) { + span_lint_and_help( + cx, + EXCESSIVE_NESTING, + span, + "this block is too nested", + None, + "try refactoring your code to minimize nesting", + ); + } + } +} + +impl EarlyLintPass for ExcessiveNesting { + fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) { +======= +>>>>>>> 5da34559e (Check if from proc macro and better tests) let mut visitor = NestingVisitor { conf: self, cx, @@ -99,6 +330,11 @@ impl EarlyLintPass for ExcessiveNesting { for item in &krate.items { visitor.visit_item(item); } +<<<<<<< HEAD + .visit_item(item); +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) } fn check_block(&mut self, cx: &EarlyContext<'_>, block: &Block) { @@ -107,15 +343,42 @@ impl EarlyLintPass for ExcessiveNesting { fn check_item(&mut self, cx: &EarlyContext<'_>, item: &Item) { self.check_node_id(cx, item.span, item.id); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } struct NestingVisitor<'conf, 'cx> { +<<<<<<< HEAD +<<<<<<< HEAD conf: &'conf mut ExcessiveNesting, +======= +<<<<<<< HEAD +<<<<<<< HEAD + conf: &'conf mut ExcessiveNesting, +======= + conf: &'conf ExcessiveNesting, +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + conf: &'conf mut ExcessiveNesting, +>>>>>>> 378d77584 (work with lint attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + conf: &'conf mut ExcessiveNesting, +>>>>>>> 615b25c20 (Rebase attempt number 2) cx: &'cx EarlyContext<'cx>, nest_level: u64, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl NestingVisitor<'_, '_> { fn check_indent(&mut self, span: Span, id: NodeId) -> bool { if self.nest_level > self.conf.excessive_nesting_threshold && !in_external_macro(self.cx.sess(), span) { @@ -145,11 +408,263 @@ impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> { if !self.check_indent(block.span, block.id) { walk_block(self, block); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> { + fn visit_local(&mut self, local: &Local) { + self.visit_pat(&local.pat); +======= +impl NestingVisitor<'_, '_> { + fn check_indent(&mut self, span: Span, id: NodeId) -> bool { + if self.nest_level > self.conf.excessive_nesting_threshold && !in_external_macro(self.cx.sess(), span) { +<<<<<<< HEAD + span_lint_and_help( + self.cx, + EXCESSIVE_NESTING, + span, + "this block is too nested", + None, + "try refactoring your code to minimize nesting", + ); +>>>>>>> 88143ac29 (decided against reinventing the wheel) +======= + self.conf.nodes.insert(id); +>>>>>>> 378d77584 (work with lint attributes) + + return true; + } + + false + } +} + +impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> { + fn visit_block(&mut self, block: &Block) { + if block.span.from_expansion() { + return; + } + + self.nest_level += 1; + +<<<<<<< HEAD +<<<<<<< HEAD + if !check_indent(self, block.span) { + for stmt in &block.stmts { + self.visit_stmt(stmt); + } +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + if !self.check_indent(block.span) { +======= + if !self.check_indent(block.span, block.id) { +>>>>>>> 378d77584 (work with lint attributes) + walk_block(self, block); +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } self.nest_level -= 1; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + fn visit_item(&mut self, item: &Item) { + if item.span.from_expansion() { + return; + } + + match &item.kind { + ItemKind::Trait(_) | ItemKind::Impl(_) | ItemKind::Mod(.., ModKind::Loaded(_, Inline::Yes, _)) => { + self.nest_level += 1; + + if !self.check_indent(item.span, item.id) { + walk_item(self, item); + } + + self.nest_level -= 1; + }, + // Reset nesting level for non-inline modules (since these are in another file) + ItemKind::Mod(..) => walk_item( + &mut NestingVisitor { + conf: self.conf, + cx: self.cx, + nest_level: 0, + }, + item, + ), + _ => walk_item(self, item), + } + } +} +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + fn visit_stmt(&mut self, stmt: &Stmt) { + match &stmt.kind { + StmtKind::Local(local) => self.visit_local(local), + StmtKind::Item(item) => self.visit_item(item), + StmtKind::Expr(expr) | StmtKind::Semi(expr) => self.visit_expr(expr), + _ => (), + } + } + + fn visit_arm(&mut self, arm: &Arm) { + self.visit_pat(&arm.pat); + if let Some(expr) = &arm.guard { + self.visit_expr(expr); + } + self.visit_expr(&arm.body); + } + + // TODO: Is this necessary? + fn visit_pat(&mut self, pat: &Pat) { + match &pat.kind { + PatKind::Box(pat) | PatKind::Ref(pat, ..) | PatKind::Paren(pat) => self.visit_pat(pat), + PatKind::Lit(expr) => self.visit_expr(expr), + PatKind::Range(start, end, ..) => { + if let Some(expr) = start { + self.visit_expr(expr); + } + if let Some(expr) = end { + self.visit_expr(expr); + } + }, + PatKind::Ident(.., pat) if let Some(pat) = pat => { + self.visit_pat(pat); + }, + PatKind::Struct(.., pat_fields, _) => { + for pat_field in pat_fields { + self.visit_pat(&pat_field.pat); + } + }, + PatKind::TupleStruct(.., pats) | PatKind::Or(pats) | PatKind::Tuple(pats) | PatKind::Slice(pats) => { + for pat in pats { + self.visit_pat(pat); + } + }, + _ => (), + } + } + + fn visit_expr(&mut self, expr: &Expr) { + // This is a mess, but really all it does is extract every expression from every applicable variant + // of ExprKind until it finds a Block. + // TODO: clippy_utils has the two functions for_each_expr and for_each_expr_with_closures, can those + // be used here or are they not applicable for this case? + match &expr.kind { + ExprKind::ConstBlock(anon_const) => self.visit_expr(&anon_const.value), + ExprKind::Call(.., args) => { + for expr in args { + self.visit_expr(expr); + } + }, + ExprKind::MethodCall(method_call) => { + for expr in &method_call.args { + self.visit_expr(expr); + } + }, + ExprKind::Tup(exprs) | ExprKind::Array(exprs) => { + for expr in exprs { + self.visit_expr(expr); + } + }, + ExprKind::Binary(.., left, right) + | ExprKind::Assign(left, right, ..) + | ExprKind::AssignOp(.., left, right) + | ExprKind::Index(left, right) => { + self.visit_expr(left); + self.visit_expr(right); + }, + ExprKind::Let(pat, expr, ..) => { + self.visit_pat(pat); + self.visit_expr(expr); + }, + ExprKind::Unary(.., expr) + | ExprKind::Await(expr) + | ExprKind::Field(expr, ..) + | ExprKind::AddrOf(.., expr) + | ExprKind::Try(expr) => { + self.visit_expr(expr); + }, + ExprKind::Repeat(expr, anon_const) => { + self.visit_expr(expr); + self.visit_expr(&anon_const.value); + }, + ExprKind::If(expr, block, else_expr) => { + self.visit_expr(expr); + self.visit_block(block); + + if let Some(expr) = else_expr { + self.visit_expr(expr); + } + }, + ExprKind::While(expr, block, ..) => { + self.visit_expr(expr); + self.visit_block(block); + }, + ExprKind::ForLoop(pat, expr, block, ..) => { + self.visit_pat(pat); + self.visit_expr(expr); + self.visit_block(block); + }, + ExprKind::Loop(block, ..) + | ExprKind::Block(block, ..) + | ExprKind::Async(.., block) + | ExprKind::TryBlock(block) => { + self.visit_block(block); + }, + ExprKind::Match(expr, arms) => { + self.visit_expr(expr); + + for arm in arms { + self.visit_arm(arm); + } + }, + ExprKind::Closure(closure) => self.visit_expr(&closure.body), + ExprKind::Range(start, end, ..) => { + if let Some(expr) = start { + self.visit_expr(expr); + } + if let Some(expr) = end { + self.visit_expr(expr); + } + }, + ExprKind::Break(.., expr) | ExprKind::Ret(expr) | ExprKind::Yield(expr) | ExprKind::Yeet(expr) => { + if let Some(expr) = expr { + self.visit_expr(expr); + } + }, + ExprKind::Struct(struct_expr) => { + for field in &struct_expr.fields { + self.visit_expr(&field.expr); + } + }, + _ => (), + } + } + + fn visit_fn(&mut self, fk: FnKind<'_>, _: Span, _: NodeId) { + match fk { + FnKind::Fn(.., block) if let Some(block) = block => self.visit_block(block), + FnKind::Closure(.., expr) => self.visit_expr(expr), + // :/ + FnKind::Fn(..) => (), + } + } + +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) fn visit_item(&mut self, item: &Item) { if item.span.from_expansion() { return; @@ -178,3 +693,45 @@ impl<'conf, 'cx> Visitor<'_> for NestingVisitor<'conf, 'cx> { } } } +<<<<<<< HEAD + +fn check_trait_and_impl(visitor: &mut NestingVisitor<'_, '_>, item: &Item, items: &ThinVec>>) { + visitor.nest_level += 1; + + if !check_indent(visitor, item.span) { + for item in items { + match &item.kind { + AssocItemKind::Const(const_item) if let Some(expr) = const_item.expr.as_ref() => { + visitor.visit_expr(expr); + }, + AssocItemKind::Fn(fk) if let Some(block) = fk.body.as_ref() => visitor.visit_block(block), + _ => (), + } + } + } + + visitor.nest_level -= 1; +} + +fn check_indent(visitor: &NestingVisitor<'_, '_>, span: Span) -> bool { + if visitor.nest_level > visitor.conf.excessive_nesting_threshold && !in_external_macro(visitor.cx.sess(), span) { + span_lint_and_help( + visitor.cx, + EXCESSIVE_NESTING, + span, + "this block is too nested", + None, + "try refactoring your code, extraction is often both easier to read and less nested", + ); + + return true; + } + + false +} +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/clippy_lints/src/incorrect_impls.rs b/clippy_lints/src/incorrect_impls.rs index 166908ef4e46..6f0244a3ac09 100644 --- a/clippy_lints/src/incorrect_impls.rs +++ b/clippy_lints/src/incorrect_impls.rs @@ -138,7 +138,23 @@ impl LateLintPass<'_> for IncorrectImpls { cx, trait_impl.self_ty(), copy_def_id, +<<<<<<< HEAD +<<<<<<< HEAD &[], +======= +<<<<<<< HEAD +<<<<<<< HEAD + &[], +======= + trait_impl.substs, +>>>>>>> 10cc1684c (rename lint and disallow `clone_from`) +======= + &[], +>>>>>>> 5df1f6681 (Pass correct substs to `implements_trait` in `incorrect_impls`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + &[], +>>>>>>> 615b25c20 (Rebase attempt number 2) ) { if impl_item.ident.name == sym::clone { diff --git a/clippy_lints/src/items_after_test_module.rs b/clippy_lints/src/items_after_test_module.rs index 55a43e915628..27ee44a14200 100644 --- a/clippy_lints/src/items_after_test_module.rs +++ b/clippy_lints/src/items_after_test_module.rs @@ -4,7 +4,23 @@ use rustc_hir::{HirId, ItemId, ItemKind, Mod}; use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_lint_pass, declare_tool_lint}; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_span::{sym, Span}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use rustc_span::{sym, Span}; +======= +use rustc_span::sym; +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= +use rustc_span::{sym, Span}; +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_span::{sym, Span}; +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_clippy_lint! { /// ### What it does @@ -44,16 +60,56 @@ declare_lint_pass!(ItemsAfterTestModule => [ITEMS_AFTER_TEST_MODULE]); impl LateLintPass<'_> for ItemsAfterTestModule { fn check_mod(&mut self, cx: &LateContext<'_>, _: &Mod<'_>, _: HirId) { let mut was_test_mod_visited = false; +<<<<<<< HEAD +<<<<<<< HEAD + let mut test_mod_span: Option = None; +======= +<<<<<<< HEAD +<<<<<<< HEAD let mut test_mod_span: Option = None; +======= + let mut test_mod_hash: Option = None; +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= + let mut test_mod_span: Option = None; +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let mut test_mod_span: Option = None; +>>>>>>> 615b25c20 (Rebase attempt number 2) let hir = cx.tcx.hir(); let items = hir.items().collect::>(); +<<<<<<< HEAD +<<<<<<< HEAD + for (i, itid) in items.iter().enumerate() { +======= +<<<<<<< HEAD +<<<<<<< HEAD for (i, itid) in items.iter().enumerate() { +======= + for itid in &items { +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= + for (i, itid) in items.iter().enumerate() { +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for (i, itid) in items.iter().enumerate() { +>>>>>>> 615b25c20 (Rebase attempt number 2) let item = hir.item(*itid); if_chain! { if was_test_mod_visited; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if i == (items.len() - 3 /* Weird magic number (HIR-translation behaviour) */); if cx.sess().source_map().lookup_char_pos(item.span.lo()).file.name_hash == cx.sess().source_map().lookup_char_pos(test_mod_span.unwrap().lo()).file.name_hash; // Will never fail @@ -64,13 +120,68 @@ impl LateLintPass<'_> for ItemsAfterTestModule { then { span_lint_and_help(cx, ITEMS_AFTER_TEST_MODULE, test_mod_span.unwrap().with_hi(item.span.hi()), "items were found after the testing module", None, "move the items to before the testing module was defined"); +<<<<<<< HEAD + }}; + +======= +<<<<<<< HEAD + + then { + span_lint_and_help(cx, ITEMS_AFTER_TEST_MODULE, test_mod_span.unwrap().with_hi(item.span.hi()), "items were found after the testing module", None, "move the items to before the testing module was defined"); +======= +======= + if i == (items.len() - 3 /* Weird magic number (HIR-translation behaviour) */); +>>>>>>> 1ac8dc51b (Compact emmited lint) + if cx.sess().source_map().lookup_char_pos(item.span.lo()).file.name_hash + == cx.sess().source_map().lookup_char_pos(test_mod_span.unwrap().lo()).file.name_hash; // Will never fail + if !matches!(item.kind, ItemKind::Mod(_)); + if !is_in_cfg_test(cx.tcx, itid.hir_id()); // The item isn't in the testing module itself + if !in_external_macro(cx.sess(), item.span); +======= +>>>>>>> 62c9e0b87 (Ignore in-proc-macros items) + + then { +<<<<<<< HEAD + span_lint_and_help(cx, ITEMS_AFTER_TEST_MODULE, item.span, "an item was found after the testing module", None, "move the item to before the testing module was defined"); +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= + span_lint_and_help(cx, ITEMS_AFTER_TEST_MODULE, test_mod_span.unwrap().with_hi(item.span.hi()), "items were found after the testing module", None, "move the items to before the testing module was defined"); +>>>>>>> 1ac8dc51b (Compact emmited lint) + }}; + +<<<<<<< HEAD +<<<<<<< HEAD + if matches!(item.kind, ItemKind::Mod(_)) { + for attr in cx.tcx.get_attrs(item.owner_id.to_def_id(), sym::cfg) { + if_chain! { +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 1ac8dc51b (Compact emmited lint) + if attr.has_name(sym::cfg); +======= +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= }}; +>>>>>>> 615b25c20 (Rebase attempt number 2) if let ItemKind::Mod(module) = item.kind && item.span.hi() == module.spans.inner_span.hi() { // Check that it works the same way, the only I way I've found for #10713 for attr in cx.tcx.get_attrs(item.owner_id.to_def_id(), sym::cfg) { if_chain! { if attr.has_name(sym::cfg); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 273c898ae (Fix #10713 and move the tests to a subdir) +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Some(mitems) = attr.meta_item_list(); if let [mitem] = &*mitems; if mitem.has_name(sym::test); @@ -79,6 +190,26 @@ impl LateLintPass<'_> for ItemsAfterTestModule { test_mod_span = Some(item.span); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if attr.has_name(sym::cfg); + if let Some(mitems) = attr.meta_item_list(); + if let [mitem] = &*mitems; + if mitem.has_name(sym::test); + then { + was_test_mod_visited = true; + test_mod_hash = Some(cx.sess().source_map().lookup_char_pos(item.span.lo()).file.name_hash); + } + } +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } diff --git a/clippy_lints/src/large_stack_frames.rs b/clippy_lints/src/large_stack_frames.rs index 7aa1446d53d5..ae44f92ff057 100644 --- a/clippy_lints/src/large_stack_frames.rs +++ b/clippy_lints/src/large_stack_frames.rs @@ -1,7 +1,28 @@ use std::ops::AddAssign; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_note; use clippy_utils::fn_has_unsatisfiable_preds; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::fn_has_unsatisfiable_preds; +<<<<<<< HEAD +======= +use clippy_utils::diagnostics::span_lint_and_then; +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= +use clippy_utils::diagnostics::span_lint_and_note; +>>>>>>> 6b232fdee (use span_lint_and_note) +======= +>>>>>>> de7d43bc6 (make lint description easier to read, prevent ICE) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::diagnostics::span_lint_and_note; +use clippy_utils::fn_has_unsatisfiable_preds; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::FnKind; use rustc_hir::{Body, FnDecl}; @@ -26,7 +47,23 @@ declare_clippy_lint! { /// /// Keep in mind that the code path to construction of large types does not even need to be reachable; /// it purely needs to *exist* inside of the function to contribute to the stack size. +<<<<<<< HEAD +<<<<<<< HEAD + /// For example, this causes a stack overflow even though the branch is unreachable: +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// For example, this causes a stack overflow even though the branch is unreachable: +======= + /// For example, this causes a stack overflow even though the branch is unreachable (with `-Zmir-opt-level=0`): +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + /// For example, this causes a stack overflow even though the branch is unreachable: +>>>>>>> de7d43bc6 (make lint description easier to read, prevent ICE) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= /// For example, this causes a stack overflow even though the branch is unreachable: +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ```rust,ignore /// fn main() { /// if false { @@ -36,15 +73,57 @@ declare_clippy_lint! { /// } /// ``` /// +<<<<<<< HEAD +<<<<<<< HEAD /// ### Known issues +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// ### Known issues +======= + /// ### Drawbacks +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + /// ### Known issues +>>>>>>> 7aa4babb5 (rename "drawbacks" to "known issues") +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// ### Known issues +>>>>>>> 615b25c20 (Rebase attempt number 2) /// False positives. The stack size that clippy sees is an estimated value and can be vastly different /// from the actual stack usage after optimizations passes have run (especially true in release mode). /// Modern compilers are very smart and are able to optimize away a lot of unnecessary stack allocations. /// In debug mode however, it is usually more accurate. /// +<<<<<<< HEAD +<<<<<<< HEAD + /// This lint works by summing up the size of all variables that the user typed, variables that were + /// implicitly introduced by the compiler for temporaries, function arguments and the return value, + /// and comparing them against a (configurable, but high-by-default). +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// This lint works by summing up the size of all variables that the user typed, variables that were + /// implicitly introduced by the compiler for temporaries, function arguments and the return value, + /// and comparing them against a (configurable, but high-by-default). +======= + /// This lint works by summing up the size of all locals and comparing them against a (configurable, but high-by-default) + /// threshold. + /// Note that "locals" in this context refers to [MIR locals](https://rustc-dev-guide.rust-lang.org/mir/index.html#key-mir-vocabulary), + /// i.e. real local variables that the user typed, storage for temporary values, function arguments + /// and the return value. +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + /// This lint works by summing up the size of all variables that the user typed, variables that were + /// implicitly introduced by the compiler for temporaries, function arguments and the return value, + /// and comparing them against a (configurable, but high-by-default). +>>>>>>> de7d43bc6 (make lint description easier to read, prevent ICE) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= /// This lint works by summing up the size of all variables that the user typed, variables that were /// implicitly introduced by the compiler for temporaries, function arguments and the return value, /// and comparing them against a (configurable, but high-by-default). +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Example /// This function creates four 500 KB arrays on the stack. Quite big but just small enough to not trigger `large_stack_arrays`. @@ -113,7 +192,25 @@ impl AddAssign for Space { if let Self::Used(lhs) = self { match lhs.checked_add(rhs) { Some(sum) => *self = Self::Used(sum), +<<<<<<< HEAD +<<<<<<< HEAD None => *self = Self::Overflow, +======= +<<<<<<< HEAD +<<<<<<< HEAD + None => *self = Self::Overflow, +======= + None => { + *self = Self::Overflow; + }, +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + None => *self = Self::Overflow, +>>>>>>> 52c6ef77f (fmt) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + None => *self = Self::Overflow, +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } @@ -130,10 +227,31 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { local_def_id: LocalDefId, ) { let def_id = local_def_id.to_def_id(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> de7d43bc6 (make lint description easier to read, prevent ICE) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Building MIR for `fn`s with unsatisfiable preds results in ICE. if fn_has_unsatisfiable_preds(cx, def_id) { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= +>>>>>>> de7d43bc6 (make lint description easier to read, prevent ICE) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mir = cx.tcx.optimized_mir(def_id); let param_env = cx.tcx.param_env(def_id); @@ -147,13 +265,50 @@ impl<'tcx> LateLintPass<'tcx> for LargeStackFrames { } if frame_size.exceeds_limit(self.maximum_allowed_size) { +<<<<<<< HEAD +<<<<<<< HEAD + span_lint_and_note( +======= +<<<<<<< HEAD +<<<<<<< HEAD span_lint_and_note( +======= + span_lint_and_then( +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + span_lint_and_note( +>>>>>>> 6b232fdee (use span_lint_and_note) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + span_lint_and_note( +>>>>>>> 615b25c20 (Rebase attempt number 2) cx, LARGE_STACK_FRAMES, span, "this function allocates a large amount of stack space", +<<<<<<< HEAD +<<<<<<< HEAD + None, + "allocating large amounts of stack space can overflow the stack", +======= +<<<<<<< HEAD +<<<<<<< HEAD + None, + "allocating large amounts of stack space can overflow the stack", +======= + |diag| { + diag.note("allocating large amounts of stack space can overflow the stack"); + }, +>>>>>>> 7312a93a0 (new lint: `large_stack_frames`) +======= + None, + "allocating large amounts of stack space can overflow the stack", +>>>>>>> 6b232fdee (use span_lint_and_note) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= None, "allocating large amounts of stack space can overflow the stack", +>>>>>>> 615b25c20 (Rebase attempt number 2) ); } } diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index b505a4e0af9e..d98025d6904f 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -192,16 +192,69 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { if local.pat.default_binding_modes && local.ty.is_none() { // When `default_binding_modes` is true, the `let` keyword is present. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cfa5aa2aa (Don't suggest unnameable types in box_default, let_underscore_untyped) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Ignore unnameable types if let Some(init) = local.init && !cx.typeck_results().expr_ty(init).is_suggestable(cx.tcx, true) { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + // Ignore function calls that return impl traits... + if let Some(init) = local.init && + matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) { + let expr_ty = cx.typeck_results().expr_ty(init); + if expr_ty.is_impl_trait() { + return; + } + } +>>>>>>> 2d9d81fc1 (Checking for proc_macro not only when local.init is Some) +======= +>>>>>>> cfa5aa2aa (Don't suggest unnameable types in box_default, let_underscore_untyped) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Ignore if it is from a procedural macro... if is_from_proc_macro(cx, init) { return; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if let Some(init) = local.init { + // Ignore function calls that return impl traits... + if matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) { + let expr_ty = cx.typeck_results().expr_ty(init); + if expr_ty.is_impl_trait() { + return; + } + } + // Ignore if it is from a procedural macro... + if is_from_proc_macro(cx, init) { + return; + } +>>>>>>> e234dfa63 (Ignoring `let_underscore_untyped` warnings in code from proc macros) +======= +>>>>>>> 2d9d81fc1 (Checking for proc_macro not only when local.init is Some) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } span_lint_and_help( diff --git a/clippy_lints/src/let_with_type_underscore.rs b/clippy_lints/src/let_with_type_underscore.rs index 4e9d77ea156a..23637fab0f48 100644 --- a/clippy_lints/src/let_with_type_underscore.rs +++ b/clippy_lints/src/let_with_type_underscore.rs @@ -1,5 +1,18 @@ use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::source::snippet; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +use clippy_utils::{diagnostics::span_lint_and_help, is_from_proc_macro}; +>>>>>>> 0cc1454db (Fix #10498) +======= +use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::source::snippet; +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{Local, TyKind}; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::lint::in_external_macro; @@ -33,9 +46,40 @@ impl LateLintPass<'_> for UnderscoreTyped { if let TyKind::Infer = &ty.kind; // that type is '_' if local.span.ctxt() == ty.span.ctxt(); then { +<<<<<<< HEAD +<<<<<<< HEAD + // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized, + // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty` + if snippet(cx, ty.span, "_").trim() != "_" { +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized, + // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty` + if snippet(cx, ty.span, "_").trim() != "_" { +======= + if let Some(init) = local.init && is_from_proc_macro(cx, init) { +>>>>>>> 0cc1454db (Fix #10498) +======= + let underscore_span = ty.span.with_lo(local.pat.span.hi()); + let snippet = snippet(cx, underscore_span, ": _"); + + // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized, + // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty` + if !snippet.trim().starts_with(':') && !snippet.trim().ends_with('_') { +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +======= + // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized, + // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty` + if snippet(cx, ty.span, "_").trim() != "_" { +>>>>>>> ba1fb74bf (check for `_` instead) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized, // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty` if snippet(cx, ty.span, "_").trim() != "_" { +>>>>>>> 615b25c20 (Rebase attempt number 2) return; } diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index 5e62cfd70ec0..6e5b96ca6615 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -123,7 +123,23 @@ mod equatable_if_let; mod escape; mod eta_reduction; mod excessive_bools; +<<<<<<< HEAD +<<<<<<< HEAD mod excessive_nesting; +======= +<<<<<<< HEAD +<<<<<<< HEAD +mod excessive_nesting; +======= +mod excessive_width; +>>>>>>> 97c10075e (add the `excessive_*` style lints) +======= +mod excessive_nesting; +>>>>>>> e68dbc330 (add `excessive_nesting`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +mod excessive_nesting; +>>>>>>> 615b25c20 (Rebase attempt number 2) mod exhaustive_items; mod exit; mod explicit_write; @@ -188,7 +204,30 @@ mod manual_is_ascii_check; mod manual_let_else; mod manual_main_separator_str; mod manual_non_exhaustive; +<<<<<<< HEAD +<<<<<<< HEAD +mod manual_range_patterns; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +mod manual_partial_ord_impl; +>>>>>>> 2a1fd22f8 (implement `manual_partial_ord_impl`) +======= +>>>>>>> 004e89d4c (rename to `manual_partial_ord_and_ord_impl`) +mod manual_range_patterns; +======= +mod manual_range_pattern; +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +======= mod manual_range_patterns; +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +mod manual_range_patterns; +>>>>>>> 615b25c20 (Rebase attempt number 2) mod manual_rem_euclid; mod manual_retain; mod manual_slice_size_calculation; @@ -289,10 +328,41 @@ mod semicolon_if_nothing_returned; mod serde_api; mod shadow; mod significant_drop_tightening; +<<<<<<< HEAD +<<<<<<< HEAD +mod single_call_fn; +mod single_char_lifetime_names; +mod single_component_path_imports; +mod single_range_in_vec_init; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod single_call_fn; mod single_char_lifetime_names; mod single_component_path_imports; mod single_range_in_vec_init; +<<<<<<< HEAD +======= +mod single_letter_idents; +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +======= +mod single_char_idents; +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +mod single_char_lifetime_names; +mod single_component_path_imports; +>>>>>>> e2ecb132a (rename the lint) +======= +mod single_range_in_vec_init; +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod size_of_in_element_count; mod size_of_ref; mod slow_vector_initialization; @@ -516,10 +586,33 @@ pub fn explain(name: &str) -> i32 { println!(" - {}: {} (default: {})", conf.name, conf.doc, conf.default); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 894d5dafa (Make `--explain` subcommand return 1 for missing lints) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) 0 } else { println!("unknown lint: {name}"); 1 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + } else { + println!("unknown lint: {name}"); +>>>>>>> a94aac607 (Refactor to make following commit pass single_match_else lint) +======= +>>>>>>> 894d5dafa (Make `--explain` subcommand return 1 for missing lints) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } @@ -931,11 +1024,35 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: )) }); let accept_comment_above_statement = conf.accept_comment_above_statement; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let accept_comment_above_attributes = conf.accept_comment_above_attributes; store.register_late_pass(move |_| { Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::new( accept_comment_above_statement, accept_comment_above_attributes, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + store.register_late_pass(move |_| { + Box::new(undocumented_unsafe_blocks::UndocumentedUnsafeBlocks::new( + accept_comment_above_statement, +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) )) }); let allow_mixed_uninlined = conf.allow_mixed_uninlined_format_args; @@ -1029,10 +1146,22 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_late_pass(|_| Box::new(tests_outside_test_module::TestsOutsideTestModule)); store.register_late_pass(|_| Box::new(manual_slice_size_calculation::ManualSliceSizeCalculation)); store.register_early_pass(|| Box::new(suspicious_doc_comments::SuspiciousDocComments)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e68dbc330 (add `excessive_nesting`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let excessive_nesting_threshold = conf.excessive_nesting_threshold; store.register_early_pass(move || { Box::new(excessive_nesting::ExcessiveNesting { excessive_nesting_threshold, +<<<<<<< HEAD +<<<<<<< HEAD nodes: rustc_ast::node_id::NodeSet::new(), }) }); @@ -1045,22 +1174,79 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: store.register_late_pass(|_| Box::new(redundant_type_annotations::RedundantTypeAnnotations)); store.register_late_pass(|_| Box::new(arc_with_non_send_sync::ArcWithNonSendSync)); store.register_late_pass(|_| Box::new(needless_if::NeedlessIf)); +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + nodes: rustc_ast::node_id::NodeSet::new(), + }) + }); + store.register_late_pass(|_| Box::new(items_after_test_module::ItemsAfterTestModule)); + store.register_early_pass(|| Box::new(ref_patterns::RefPatterns)); + store.register_late_pass(|_| Box::new(default_constructed_unit_structs::DefaultConstructedUnitStructs)); + store.register_early_pass(|| Box::new(needless_else::NeedlessElse)); + store.register_late_pass(|_| Box::new(missing_fields_in_debug::MissingFieldsInDebug)); + store.register_late_pass(|_| Box::new(endian_bytes::EndianBytes)); + store.register_late_pass(|_| Box::new(redundant_type_annotations::RedundantTypeAnnotations)); + store.register_late_pass(|_| Box::new(arc_with_non_send_sync::ArcWithNonSendSync)); + store.register_late_pass(|_| Box::new(needless_if::NeedlessIf)); +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let allowed_idents_below_min_chars = conf.allowed_idents_below_min_chars.clone(); let min_ident_chars_threshold = conf.min_ident_chars_threshold; store.register_late_pass(move |_| { Box::new(min_ident_chars::MinIdentChars { allowed_idents_below_min_chars: allowed_idents_below_min_chars.clone(), min_ident_chars_threshold, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }) }); let stack_size_threshold = conf.stack_size_threshold; store.register_late_pass(move |_| Box::new(large_stack_frames::LargeStackFrames::new(stack_size_threshold))); +<<<<<<< HEAD +<<<<<<< HEAD + store.register_late_pass(|_| Box::new(single_range_in_vec_init::SingleRangeInVecInit)); +======= +<<<<<<< HEAD +<<<<<<< HEAD + store.register_late_pass(|_| Box::new(single_range_in_vec_init::SingleRangeInVecInit)); +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= + store.register_late_pass(|_| Box::new(needless_pass_by_ref_mut::NeedlessPassByRefMut)); +>>>>>>> b41fc6784 (Add needless_pass_by_ref lint) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= store.register_late_pass(|_| Box::new(single_range_in_vec_init::SingleRangeInVecInit)); +>>>>>>> 615b25c20 (Rebase attempt number 2) store.register_late_pass(move |_| { Box::new(needless_pass_by_ref_mut::NeedlessPassByRefMut::new( avoid_breaking_exported_api, )) }); +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f048f7325 (Add warning about semver compatibility if it's a public function) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) store.register_late_pass(|_| Box::new(incorrect_impls::IncorrectImpls)); store.register_late_pass(move |_| { Box::new(single_call_fn::SingleCallFn { @@ -1068,16 +1254,43 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: def_id_to_usage: rustc_data_structures::fx::FxHashMap::default(), }) }); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let needless_raw_string_hashes_allow_one = conf.allow_one_hash_in_raw_strings; store.register_early_pass(move || { Box::new(raw_strings::RawStrings { needless_raw_string_hashes_allow_one, }) }); +<<<<<<< HEAD +<<<<<<< HEAD + store.register_late_pass(|_| Box::new(manual_range_patterns::ManualRangePatterns)); + store.register_early_pass(|| Box::new(visibility::Visibility)); + store.register_late_pass(move |_| Box::new(tuple_array_conversions::TupleArrayConversions { msrv: msrv() })); + store.register_late_pass(|_| Box::new(manual_float_methods::ManualFloatMethods)); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) store.register_late_pass(|_| Box::new(manual_range_patterns::ManualRangePatterns)); store.register_early_pass(|| Box::new(visibility::Visibility)); store.register_late_pass(move |_| Box::new(tuple_array_conversions::TupleArrayConversions { msrv: msrv() })); store.register_late_pass(|_| Box::new(manual_float_methods::ManualFloatMethods)); +<<<<<<< HEAD +>>>>>>> f12edfdb5 (`manual_float_methods`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // add lints here, do not remove this comment, it's used in `new_lint` } diff --git a/clippy_lints/src/loops/explicit_into_iter_loop.rs b/clippy_lints/src/loops/explicit_into_iter_loop.rs index 93d6b8086469..98d95a035630 100644 --- a/clippy_lints/src/loops/explicit_into_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_into_iter_loop.rs @@ -84,7 +84,23 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr< "it is more concise to loop over containers instead of using explicit \ iteration methods", "to write this more concisely, try", +<<<<<<< HEAD +<<<<<<< HEAD format!("{}{object}", adjust.display()), +======= +<<<<<<< HEAD +<<<<<<< HEAD + format!("{}{object}", adjust.display()), +======= + format!("{}{}", adjust.display(), object.to_string()), +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +======= + format!("{}{object}", adjust.display()), +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + format!("{}{object}", adjust.display()), +>>>>>>> 615b25c20 (Rebase attempt number 2) applicability, ); } diff --git a/clippy_lints/src/loops/explicit_iter_loop.rs b/clippy_lints/src/loops/explicit_iter_loop.rs index 5c5a4cfce884..4f1fea7d326f 100644 --- a/clippy_lints/src/loops/explicit_iter_loop.rs +++ b/clippy_lints/src/loops/explicit_iter_loop.rs @@ -1,16 +1,84 @@ use super::EXPLICIT_ITER_LOOP; use clippy_utils::diagnostics::span_lint_and_sugg; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::{ implements_trait, implements_trait_with_env, is_copy, make_normalized_projection, make_normalized_projection_with_regions, normalize_with_regions, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +use clippy_utils::is_trait_method; +use clippy_utils::msrvs::{self, Msrv}; +use clippy_utils::source::snippet_with_applicability; +use clippy_utils::ty::{implements_trait_with_env, make_normalized_projection_with_regions, normalize_with_regions, + make_normalized_projection, implements_trait, is_copy}; +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +use clippy_utils::msrvs::{self, Msrv}; +use clippy_utils::source::snippet_with_applicability; +use clippy_utils::ty::{ + implements_trait, implements_trait_with_env, is_copy, make_normalized_projection, + make_normalized_projection_with_regions, normalize_with_regions, +}; +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_errors::Applicability; use rustc_hir::{Expr, Mutability}; use rustc_lint::LateContext; use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow, AutoBorrowMutability}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use rustc_middle::ty::{self, EarlyBinder, Ty, TypeAndMut}; +use rustc_span::sym; + +pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr<'_>, msrv: &Msrv) { + let Some((adjust, ty)) = is_ref_iterable(cx, self_arg, call_expr) else { + return; + }; + if let ty::Array(_, count) = *ty.peel_refs().kind() { + if !ty.is_ref() { + if !msrv.meets(msrvs::ARRAY_INTO_ITERATOR) { + return; + } + } else if count + .try_eval_target_usize(cx.tcx, cx.param_env) + .map_or(true, |x| x > 32) + && !msrv.meets(msrvs::ARRAY_IMPL_ANY_LEN) + { + return; + } + } + + let mut applicability = Applicability::MachineApplicable; + let object = snippet_with_applicability(cx, self_arg.span, "_", &mut applicability); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +use rustc_middle::ty::{self, EarlyBinder, TypeAndMut, Ty}; +======= use rustc_middle::ty::{self, EarlyBinder, Ty, TypeAndMut}; +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) use rustc_span::sym; pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr<'_>, msrv: &Msrv) { @@ -33,6 +101,20 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr< let mut applicability = Applicability::MachineApplicable; let object = snippet_with_applicability(cx, self_arg.span, "_", &mut applicability); + let prefix = match adjust { + AdjustKind::None => "", + AdjustKind::Borrow => "&", + AdjustKind::BorrowMut => "&mut ", + AdjustKind::Deref => "*", + AdjustKind::Reborrow => "&*", + AdjustKind::ReborrowMut => "&mut *", + }; +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) span_lint_and_sugg( cx, EXPLICIT_ITER_LOOP, @@ -40,12 +122,43 @@ pub(super) fn check(cx: &LateContext<'_>, self_arg: &Expr<'_>, call_expr: &Expr< "it is more concise to loop over references to containers instead of using explicit \ iteration methods", "to write this more concisely, try", +<<<<<<< HEAD +<<<<<<< HEAD + format!("{}{object}", adjust.display()), +======= +<<<<<<< HEAD +<<<<<<< HEAD + format!("{}{object}", adjust.display()), +======= + format!("{prefix}{object}"), +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= + format!("{}{object}", adjust.display()), +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= format!("{}{object}", adjust.display()), +>>>>>>> 615b25c20 (Rebase attempt number 2) applicability, ); } +<<<<<<< HEAD +<<<<<<< HEAD #[derive(Clone, Copy)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[derive(Clone, Copy)] +======= +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +#[derive(Clone, Copy)] +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[derive(Clone, Copy)] +>>>>>>> 615b25c20 (Rebase attempt number 2) enum AdjustKind { None, Borrow, @@ -53,6 +166,8 @@ enum AdjustKind { Deref, Reborrow, ReborrowMut, +<<<<<<< HEAD +======= } impl AdjustKind { fn borrow(mutbl: Mutability) -> Self { @@ -93,16 +208,95 @@ impl AdjustKind { Self::ReborrowMut => "&mut *", } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +} +impl AdjustKind { + fn borrow(mutbl: Mutability) -> Self { + match mutbl { + Mutability::Not => Self::Borrow, + Mutability::Mut => Self::BorrowMut, + } + } + +<<<<<<< HEAD + fn auto_borrow(mutbl: AutoBorrowMutability) -> Self { + match mutbl { + AutoBorrowMutability::Not => Self::Borrow, + AutoBorrowMutability::Mut { .. } => Self::BorrowMut, + } + } + + fn reborrow(mutbl: Mutability) -> Self { + match mutbl { + Mutability::Not => Self::Reborrow, + Mutability::Mut => Self::ReborrowMut, + } + } + + fn auto_reborrow(mutbl: AutoBorrowMutability) -> Self { + match mutbl { + AutoBorrowMutability::Not => Self::Reborrow, + AutoBorrowMutability::Mut { .. } => Self::ReborrowMut, + } + } + + fn display(self) -> &'static str { + match self { + Self::None => "", + Self::Borrow => "&", + Self::BorrowMut => "&mut ", + Self::Deref => "*", + Self::Reborrow => "&*", + Self::ReborrowMut => "&mut *", + } + } +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } /// Checks if an `iter` or `iter_mut` call returns `IntoIterator::IntoIter`. Returns how the /// argument needs to be adjusted. +<<<<<<< HEAD #[expect(clippy::too_many_lines)] +======= +/// Checks if an `iter` or `iter_mut` call returns `IntoIterator::IntoIter`. Returns how the +/// argument needs to be adjusted. +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#[expect(clippy::too_many_lines)] +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +======= +#[expect(clippy::too_many_lines)] +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[expect(clippy::too_many_lines)] +>>>>>>> 615b25c20 (Rebase attempt number 2) fn is_ref_iterable<'tcx>( cx: &LateContext<'tcx>, self_arg: &Expr<'_>, call_expr: &Expr<'_>, ) -> Option<(AdjustKind, Ty<'tcx>)> { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +fn is_ref_iterable<'tcx>(cx: &LateContext<'tcx>, self_arg: &Expr<'_>, call_expr: &Expr<'_>) -> Option<(AdjustKind, Ty<'tcx>)> { +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let typeck = cx.typeck_results(); if let Some(trait_id) = cx.tcx.get_diagnostic_item(sym::IntoIterator) && let Some(fn_id) = typeck.type_dependent_def_id(call_expr.hir_id) @@ -120,17 +314,64 @@ fn is_ref_iterable<'tcx>( let self_is_copy = is_copy(cx, self_ty); if adjustments.is_empty() && self_is_copy { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Exact type match, already checked earlier return Some((AdjustKind::None, self_ty)); } let res_ty = cx.tcx.erase_regions(EarlyBinder::bind(req_res_ty) .subst(cx.tcx, typeck.node_substs(call_expr.hir_id))); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + return Some((AdjustKind::None, self_ty)); + } + + let res_ty = cx.tcx.erase_regions(EarlyBinder::bind(req_res_ty).subst(cx.tcx, typeck.node_substs(call_expr.hir_id))); + if !adjustments.is_empty() && self_is_copy { + if implements_trait(cx, self_ty, trait_id, &[]) + && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [self_ty]) + && ty == res_ty + { + return Some((AdjustKind::None, self_ty)); + } + } + +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= + // Exact type match, already checked earlier + return Some((AdjustKind::None, self_ty)); + } + + let res_ty = cx.tcx.erase_regions(EarlyBinder::bind(req_res_ty) + .subst(cx.tcx, typeck.node_substs(call_expr.hir_id))); +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mutbl = if let ty::Ref(_, _, mutbl) = *req_self_ty.kind() { Some(mutbl) } else { None }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if !adjustments.is_empty() { if self_is_copy { @@ -150,6 +391,16 @@ fn is_ref_iterable<'tcx>( self_ty } else { Ty::new_ref(cx.tcx,region, TypeAndMut { ty, mutbl }) +<<<<<<< HEAD +======= +<<<<<<< HEAD + Ty::new_ref(cx.tcx,region, TypeAndMut { ty, mutbl }) +======= + cx.tcx.mk_ref(region, TypeAndMut { ty, mutbl }) +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }; if implements_trait(cx, self_ty, trait_id, &[]) && let Some(ty) = @@ -160,11 +411,33 @@ fn is_ref_iterable<'tcx>( } } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Some(mutbl) = mutbl && !self_ty.is_ref() { // Attempt to borrow let self_ty = Ty::new_ref(cx.tcx,cx.tcx.lifetimes.re_erased, TypeAndMut { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) + if let Some(mutbl) = mutbl + && !self_ty.is_ref() + { + // Attempt to borrow + let self_ty = cx.tcx.mk_ref(cx.tcx.lifetimes.re_erased, TypeAndMut { +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ty: self_ty, mutbl, }); @@ -178,6 +451,16 @@ fn is_ref_iterable<'tcx>( match adjustments { [] => Some((AdjustKind::None, self_ty)), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) &[ Adjustment { kind: Adjust::Deref(_), ..}, Adjustment { @@ -186,13 +469,42 @@ fn is_ref_iterable<'tcx>( }, .. ] => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + if target != self_ty + && implements_trait(cx, target, trait_id, &[]) + && let Some(ty) = + make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) + && ty == res_ty + { + Some((AdjustKind::auto_reborrow(mutbl), target)) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + &[Adjustment { kind: Adjust::Deref(_), ..}, Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), target }, ..] => { +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) if target != self_ty && implements_trait(cx, target, trait_id, &[]) && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) && ty == res_ty { +<<<<<<< HEAD + Some((AdjustKind::reborrow(mutbl), target)) +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= Some((AdjustKind::auto_reborrow(mutbl), target)) +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } else { None } @@ -200,8 +512,27 @@ fn is_ref_iterable<'tcx>( &[Adjustment { kind: Adjust::Deref(_), target }, ..] => { if is_copy(cx, target) && implements_trait(cx, target, trait_id, &[]) +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(ty) = + make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +======= +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(ty) = + make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +======= + && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && let Some(ty) = + make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +>>>>>>> 615b25c20 (Rebase attempt number 2) && ty == res_ty { Some((AdjustKind::Deref, target)) @@ -209,6 +540,16 @@ fn is_ref_iterable<'tcx>( None } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) &[ Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), @@ -216,10 +557,35 @@ fn is_ref_iterable<'tcx>( }, .. ] => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + if self_ty.is_ref() + && implements_trait(cx, target, trait_id, &[]) + && let Some(ty) = + make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + &[Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(_, mutbl)), target }, ..] => { + if self_ty.is_ref() + && implements_trait(cx, target, trait_id, &[]) + && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= if self_ty.is_ref() && implements_trait(cx, target, trait_id, &[]) && let Some(ty) = make_normalized_projection(cx.tcx, cx.param_env, trait_id, sym!(IntoIter), [target]) +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && ty == res_ty { Some((AdjustKind::auto_borrow(mutbl), target)) diff --git a/clippy_lints/src/loops/mod.rs b/clippy_lints/src/loops/mod.rs index ffd29ab76302..977825c82d12 100644 --- a/clippy_lints/src/loops/mod.rs +++ b/clippy_lints/src/loops/mod.rs @@ -717,11 +717,41 @@ impl Loops { fn check_for_loop_arg(&self, cx: &LateContext<'_>, _: &Pat<'_>, arg: &Expr<'_>) { if let ExprKind::MethodCall(method, self_arg, [], _) = arg.kind { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) match method.ident.as_str() { "iter" | "iter_mut" => { explicit_iter_loop::check(cx, self_arg, arg, &self.msrv); }, "into_iter" => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let method_name = method.ident.as_str(); + // check for looping over x.iter() or x.iter_mut(), could use &x or &mut x + match method_name { +======= + match method.ident.as_str() { +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) + "iter" | "iter_mut" => { + explicit_iter_loop::check(cx, self_arg, arg, &self.msrv); + }, + "into_iter" => { +<<<<<<< HEAD + explicit_iter_loop::check(cx, self_arg, arg, method_name, &self.msrv); +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) explicit_into_iter_loop::check(cx, self_arg, arg); }, "next" => { diff --git a/clippy_lints/src/manual_let_else.rs b/clippy_lints/src/manual_let_else.rs index c531137b785e..aa79e04ab620 100644 --- a/clippy_lints/src/manual_let_else.rs +++ b/clippy_lints/src/manual_let_else.rs @@ -49,10 +49,26 @@ declare_clippy_lint! { "manual implementation of a let...else statement" } +<<<<<<< HEAD +<<<<<<< HEAD impl<'tcx> QuestionMark { pub(crate) fn check_manual_let_else(&mut self, cx: &LateContext<'_>, stmt: &'tcx Stmt<'tcx>) { if !self.msrv.meets(msrvs::LET_ELSE) || in_external_macro(cx.sess(), stmt.span) { return; +======= +<<<<<<< HEAD +pub struct ManualLetElse { + msrv: Msrv, + matches_behaviour: MatchLintBehaviour, +} + +impl ManualLetElse { + #[must_use] + pub fn new(msrv: Msrv, matches_behaviour: MatchLintBehaviour) -> Self { + Self { + msrv, + matches_behaviour, +>>>>>>> 0567691cb (This commit resolves issue #10655) } if let StmtKind::Local(local) = stmt.kind && @@ -108,9 +124,142 @@ impl<'tcx> QuestionMark { return }; +<<<<<<< HEAD emit_manual_let_else(cx, stmt.span, match_expr, &ident_map, pat_arm.pat, diverging_arm.body); }, } +======= +impl<'tcx> LateLintPass<'tcx> for ManualLetElse { + fn check_stmt(&mut self, cx: &LateContext<'_>, stmt: &'tcx Stmt<'tcx>) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 4931f4549 (Split if conditions by its semantics) +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +impl<'tcx> QuestionMark { + pub(crate) fn check_manual_let_else(&mut self, cx: &LateContext<'_>, stmt: &'tcx Stmt<'tcx>) { + if !self.msrv.meets(msrvs::LET_ELSE) || in_external_macro(cx.sess(), stmt.span) { + return; + } + + if let StmtKind::Local(local) = stmt.kind && + let Some(init) = local.init && + local.els.is_none() && + local.ty.is_none() && + init.span.ctxt() == stmt.span.ctxt() && + let Some(if_let_or_match) = IfLetOrMatch::parse(cx, init) + { + match if_let_or_match { + IfLetOrMatch::IfLet(if_let_expr, let_pat, if_then, if_else) => { + if + let Some(ident_map) = expr_simple_identity_map(local.pat, let_pat, if_then) && + let Some(if_else) = if_else && + expr_diverges(cx, if_else) && + let qm_allowed = is_lint_allowed(cx, QUESTION_MARK, stmt.hir_id) && + (qm_allowed || pat_and_expr_can_be_question_mark(cx, let_pat, if_else).is_none()) + { + emit_manual_let_else(cx, stmt.span, if_let_expr, &ident_map, let_pat, if_else); + } + }, + IfLetOrMatch::Match(match_expr, arms, source) => { + if self.matches_behaviour == MatchLintBehaviour::Never { + return; + } + if source != MatchSource::Normal { + return; + } + // Any other number than two arms doesn't (necessarily) + // have a trivial mapping to let else. + if arms.len() != 2 { + return; + } + // Guards don't give us an easy mapping either + if arms.iter().any(|arm| arm.guard.is_some()) { + return; + } + let check_types = self.matches_behaviour == MatchLintBehaviour::WellKnownTypes; + let diverging_arm_opt = arms + .iter() + .enumerate() + .find(|(_, arm)| expr_diverges(cx, arm.body) && pat_allowed_for_else(cx, arm.pat, check_types)); + let Some((idx, diverging_arm)) = diverging_arm_opt else { return; }; + // If the non-diverging arm is the first one, its pattern can be reused in a let/else statement. + // However, if it arrives in second position, its pattern may cover some cases already covered + // by the diverging one. + // TODO: accept the non-diverging arm as a second position if patterns are disjointed. + if idx == 0 { + return; + } + let pat_arm = &arms[1 - idx]; + let Some(ident_map) = expr_simple_identity_map(local.pat, pat_arm.pat, pat_arm.body) else { + return + }; + + emit_manual_let_else(cx, stmt.span, match_expr, &ident_map, pat_arm.pat, diverging_arm.body); + }, + } +<<<<<<< HEAD +======= + let Some(if_let_or_match) = IfLetOrMatch::parse(cx, init) { + match if_let_or_match { + IfLetOrMatch::IfLet(if_let_expr, let_pat, if_then, if_else) => if_chain! { + if expr_is_simple_identity(let_pat, if_then); + if let Some(if_else) = if_else; + if expr_diverges(cx, if_else); + then { + emit_manual_let_else(cx, stmt.span, if_let_expr, local.pat, let_pat, if_else); + } + }, + IfLetOrMatch::Match(match_expr, arms, source) => { + if self.matches_behaviour == MatchLintBehaviour::Never { + return; + } + if source != MatchSource::Normal { + return; + } + // Any other number than two arms doesn't (neccessarily) + // have a trivial mapping to let else. + if arms.len() != 2 { + return; + } + // Guards don't give us an easy mapping either + if arms.iter().any(|arm| arm.guard.is_some()) { + return; + } + let check_types = self.matches_behaviour == MatchLintBehaviour::WellKnownTypes; + let diverging_arm_opt = arms + .iter() + .enumerate() + .find(|(_, arm)| expr_diverges(cx, arm.body) && pat_allowed_for_else(cx, arm.pat, check_types)); + let Some((idx, diverging_arm)) = diverging_arm_opt else { return; }; + let pat_arm = &arms[1 - idx]; + if !expr_is_simple_identity(pat_arm.pat, pat_arm.body) { + return; + } + + emit_manual_let_else(cx, stmt.span, match_expr, local.pat, pat_arm.pat, diverging_arm.body); + }, + } +>>>>>>> a408e7609 (Suggest the correct variable name for `manual_let_else`) +======= + if !expr_is_simple_identity(pat_arm.pat, pat_arm.body) { + return; + } +======= + let Some(ident_map) = expr_simple_identity_map(local.pat, pat_arm.pat, pat_arm.body) else { + return + }; +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) + + emit_manual_let_else(cx, stmt.span, match_expr, &ident_map, pat_arm.pat, diverging_arm.body); + }, + } +>>>>>>> 83a4b0987 (Fix formatting of if let chain) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }; } } @@ -119,7 +268,23 @@ fn emit_manual_let_else( cx: &LateContext<'_>, span: Span, expr: &Expr<'_>, +<<<<<<< HEAD +<<<<<<< HEAD ident_map: &FxHashMap>, +======= +<<<<<<< HEAD +<<<<<<< HEAD + ident_map: &FxHashMap>, +======= + local: &Pat<'_>, +>>>>>>> a408e7609 (Suggest the correct variable name for `manual_let_else`) +======= + ident_map: &FxHashMap>, +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + ident_map: &FxHashMap>, +>>>>>>> 615b25c20 (Rebase attempt number 2) pat: &Pat<'_>, else_body: &Expr<'_>, ) { @@ -130,8 +295,33 @@ fn emit_manual_let_else( "this could be rewritten as `let...else`", |diag| { // This is far from perfect, for example there needs to be: +<<<<<<< HEAD +<<<<<<< HEAD // * renamings of the bindings for many `PatKind`s like slices, etc. // * limitations in the existing replacement algorithms +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + // * renamings of the bindings for many `PatKind`s like slices, etc. + // * limitations in the existing replacement algorithms +======= + // * mut additions for the bindings + // * renamings of the bindings for `PatKind::Or` +>>>>>>> a408e7609 (Suggest the correct variable name for `manual_let_else`) +======= + // * tracking for multi-binding cases: let (foo, bar) = if let (Some(foo), Ok(bar)) = ... + // * renamings of the bindings for many `PatKind`s like structs, slices, etc. +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= + // * renamings of the bindings for many `PatKind`s like slices, etc. + // * limitations in the existing replacement algorithms +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // * renamings of the bindings for many `PatKind`s like slices, etc. + // * limitations in the existing replacement algorithms +>>>>>>> 615b25c20 (Rebase attempt number 2) // * unused binding collision detection with existing ones // for this to be machine applicable. let mut app = Applicability::HasPlaceholders; @@ -143,13 +333,112 @@ fn emit_manual_let_else( } else { format!("{{ {sn_else} }}") }; +<<<<<<< HEAD +<<<<<<< HEAD let sn_bl = replace_in_pattern(cx, span, ident_map, pat, &mut app, true); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + let sn_bl = replace_in_pattern(cx, span, ident_map, pat, &mut app, true); +======= + let sn_bl = match pat.kind { + PatKind::Or(..) => { + let (sn_pat, _) = snippet_with_context(cx, pat.span, span.ctxt(), "", &mut app); + format!("({sn_pat})") + }, + // Replace the variable name iff `TupleStruct` has one argument like `Variant(v)`. + PatKind::TupleStruct(ref w, args, ..) if args.len() == 1 => { + let sn_wrapper = cx.sess().source_map().span_to_snippet(w.span()).unwrap_or_default(); + let (sn_inner, _) = snippet_with_context(cx, local.span, span.ctxt(), "", &mut app); + format!("{sn_wrapper}({sn_inner})") + }, + _ => { + let (sn_pat, _) = snippet_with_context(cx, pat.span, span.ctxt(), "", &mut app); + sn_pat.into_owned() + }, + }; +>>>>>>> a408e7609 (Suggest the correct variable name for `manual_let_else`) +======= + let sn_bl = replace_in_pattern(cx, span, local, pat, &mut app); +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= + let sn_bl = replace_in_pattern(cx, span, local, pat, &mut app, true); +>>>>>>> 0a7366897 (manual_let_else: only add () around PatKind::Or at the top level) +======= + let sn_bl = replace_in_pattern(cx, span, ident_map, pat, &mut app, true); +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let sn_bl = replace_in_pattern(cx, span, ident_map, pat, &mut app, true); +>>>>>>> 615b25c20 (Rebase attempt number 2) let sugg = format!("let {sn_bl} = {sn_expr} else {else_bl};"); diag.span_suggestion(span, "consider writing", sugg, app); }, ); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +======= +/// Returns whether the given let pattern and else body can be turned into a question mark +/// +/// For this example: +/// ```ignore +/// let FooBar { a, b } = if let Some(a) = ex { a } else { return None }; +/// ``` +/// We get as parameters: +/// ```ignore +/// pat: Some(a) +/// else_body: return None +/// ``` + +/// And for this example: +/// ```ignore +/// let Some(FooBar { a, b }) = ex else { return None }; +/// ``` +/// We get as parameters: +/// ```ignore +/// pat: Some(FooBar { a, b }) +/// else_body: return None +/// ``` + +/// We output `Some(a)` in the first instance, and `Some(FooBar { a, b })` in the second, because +/// the question mark operator is applicable here. Callers have to check whether we are in a +/// constant or not. +pub fn pat_and_expr_can_be_question_mark<'a, 'hir>( + cx: &LateContext<'_>, + pat: &'a Pat<'hir>, + else_body: &Expr<'_>, +) -> Option<&'a Pat<'hir>> { + if let PatKind::TupleStruct(pat_path, [inner_pat], _) = pat.kind && + is_res_lang_ctor(cx, cx.qpath_res(&pat_path, pat.hir_id), OptionSome) && + !is_refutable(cx, inner_pat) && + let else_body = peel_blocks(else_body) && + let ExprKind::Ret(Some(ret_val)) = else_body.kind && + let ExprKind::Path(ret_path) = ret_val.kind && + is_res_lang_ctor(cx, cx.qpath_res(&ret_path, ret_val.hir_id), OptionNone) + { + Some(inner_pat) + } else { + None + } +} + +>>>>>>> 86391abc7 (Don't lint manual_let_else in cases where the question mark operator would work) +======= +>>>>>>> 20dfaba03 (Put into one pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Replaces the locals in the pattern /// /// For this example: @@ -170,6 +459,13 @@ fn emit_manual_let_else( /// ```ignore /// Bar { Some(a), b_i: FooBar { b, c } } /// ``` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn replace_in_pattern( cx: &LateContext<'_>, span: Span, @@ -191,9 +487,19 @@ fn replace_in_pattern( match pat.kind { PatKind::Binding(_ann, _id, binding_name, opt_subpt) => { +<<<<<<< HEAD +<<<<<<< HEAD let Some(pat_to_put) = ident_map.get(&binding_name.name) else { break 'a; }; +======= + let Some(pat_to_put) = ident_map.get(&binding_name.name) else { break 'a }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let Some(pat_to_put) = ident_map.get(&binding_name.name) else { + break 'a; + }; +>>>>>>> 615b25c20 (Rebase attempt number 2) let (sn_ptp, _) = snippet_with_context(cx, pat_to_put.span, span.ctxt(), "", app); if let Some(subpt) = opt_subpt { let subpt = replace_in_pattern(cx, span, ident_map, subpt, app, false); @@ -265,6 +571,102 @@ fn replace_in_pattern( }, _ => {}, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +// replaces the locals in the pattern +======= +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +fn replace_in_pattern( + cx: &LateContext<'_>, + span: Span, + ident_map: &FxHashMap>, + pat: &Pat<'_>, + app: &mut Applicability, + top_level: bool, +) -> String { + // We put a labeled block here so that we can implement the fallback in this function. + // As the function has multiple call sites, implementing the fallback via an Option + // return type and unwrap_or_else would cause repetition. Similarly, the function also + // invokes the fall back multiple times. + 'a: { + // If the ident map is empty, there is no replacement to do. + // The code following this if assumes a non-empty ident_map. + if ident_map.is_empty() { + break 'a; + } + + match pat.kind { + PatKind::Binding(_ann, _id, binding_name, opt_subpt) => { + let Some(pat_to_put) = ident_map.get(&binding_name.name) else { break 'a }; + let (sn_ptp, _) = snippet_with_context(cx, pat_to_put.span, span.ctxt(), "", app); + if let Some(subpt) = opt_subpt { + let subpt = replace_in_pattern(cx, span, ident_map, subpt, app, false); + return format!("{sn_ptp} @ {subpt}"); + } + return sn_ptp.to_string(); + }, + PatKind::Or(pats) => { + let patterns = pats + .iter() + .map(|pat| replace_in_pattern(cx, span, ident_map, pat, app, false)) + .collect::>(); + let or_pat = patterns.join(" | "); + if top_level { + return format!("({or_pat})"); + } + return or_pat; +<<<<<<< HEAD + } + }, + // Replace the variable name iff `TupleStruct` has one argument like `Variant(v)`. + PatKind::TupleStruct(ref w, args, dot_dot_pos) => { + let mut args = args + .iter() + .map(|pat| replace_in_pattern(cx, span, local, pat, app, false)) + .collect::>(); + if let Some(pos) = dot_dot_pos.as_opt_usize() { + args.insert(pos, "..".to_owned()); + } + let args = args.join(", "); + let sn_wrapper = cx.sess().source_map().span_to_snippet(w.span()).unwrap_or_default(); + return format!("{sn_wrapper}({args})"); + }, + _ => {}, +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= + }, + // Replace the variable name iff `TupleStruct` has one argument like `Variant(v)`. + PatKind::TupleStruct(ref w, args, dot_dot_pos) => { + let mut args = args + .iter() + .map(|pat| replace_in_pattern(cx, span, ident_map, pat, app, false)) + .collect::>(); + if let Some(pos) = dot_dot_pos.as_opt_usize() { + args.insert(pos, "..".to_owned()); + } + let args = args.join(", "); + let sn_wrapper = cx.sess().source_map().span_to_snippet(w.span()).unwrap_or_default(); + return format!("{sn_wrapper}({args})"); + }, + PatKind::Tuple(args, dot_dot_pos) => { + let mut args = args + .iter() + .map(|pat| replace_in_pattern(cx, span, ident_map, pat, app, false)) + .collect::>(); + if let Some(pos) = dot_dot_pos.as_opt_usize() { + args.insert(pos, "..".to_owned()); + } + let args = args.join(", "); + return format!("({args})"); + }, + _ => {}, + } +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } let (sn_pat, _) = snippet_with_context(cx, pat.span, span.ctxt(), "", app); sn_pat.into_owned() diff --git a/clippy_lints/src/manual_slice_size_calculation.rs b/clippy_lints/src/manual_slice_size_calculation.rs index 703a6b25840b..d2695ac6cc4c 100644 --- a/clippy_lints/src/manual_slice_size_calculation.rs +++ b/clippy_lints/src/manual_slice_size_calculation.rs @@ -1,6 +1,22 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet_with_context; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::{expr_or_init, in_constant, std_or_core}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{expr_or_init, in_constant, std_or_core}; +======= +use clippy_utils::{expr_or_init, in_constant}; +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= +use clippy_utils::{expr_or_init, in_constant, std_or_core}; +>>>>>>> a2580db64 (Use `clippy_utils::std_or_core` in manual slice size calculation lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::{expr_or_init, in_constant, std_or_core}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_errors::Applicability; use rustc_hir::{BinOpKind, Expr, ExprKind}; use rustc_lint::{LateContext, LateLintPass}; @@ -44,23 +60,85 @@ impl<'tcx> LateLintPass<'tcx> for ManualSliceSizeCalculation { if !in_constant(cx, expr.hir_id) && let ExprKind::Binary(ref op, left, right) = expr.kind && BinOpKind::Mul == op.node +<<<<<<< HEAD +<<<<<<< HEAD + && !expr.span.from_expansion() +======= +<<<<<<< HEAD +<<<<<<< HEAD + && !expr.span.from_expansion() +======= +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= + && !expr.span.from_expansion() +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= && !expr.span.from_expansion() +>>>>>>> 615b25c20 (Rebase attempt number 2) && let Some(receiver) = simplify(cx, left, right) { let ctxt = expr.span.ctxt(); let mut app = Applicability::MachineApplicable; let val_name = snippet_with_context(cx, receiver.span, ctxt, "slice", &mut app).0; +<<<<<<< HEAD +<<<<<<< HEAD let Some(sugg) = std_or_core(cx) else { return }; +======= +<<<<<<< HEAD +<<<<<<< HEAD + let Some(sugg) = std_or_core(cx) else { return }; +======= +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= + let Some(sugg) = std_or_core(cx) else { return }; +>>>>>>> a2580db64 (Use `clippy_utils::std_or_core` in manual slice size calculation lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let Some(sugg) = std_or_core(cx) else { return }; +>>>>>>> 615b25c20 (Rebase attempt number 2) span_lint_and_sugg( cx, MANUAL_SLICE_SIZE_CALCULATION, expr.span, "manual slice size calculation", +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + expr.span, + "manual slice size calculation", +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "try", format!("{sugg}::mem::size_of_val({val_name})"), app, ); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + None, + "consider using std::mem::size_of_val instead"); +>>>>>>> 4fb38cfb2 (Rename std::mem::size_of_value to std::mem::size_of_val) +======= + expr.span, + "manual slice size calculation", + "try", + format!("{sugg}::mem::size_of_val({val_name})"), + Applicability::MachineApplicable, + ); +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } diff --git a/clippy_lints/src/matches/match_like_matches.rs b/clippy_lints/src/matches/match_like_matches.rs index e2ddf11abe2c..ab01460a050c 100644 --- a/clippy_lints/src/matches/match_like_matches.rs +++ b/clippy_lints/src/matches/match_like_matches.rs @@ -181,9 +181,48 @@ fn find_bool_lit(ex: &ExprKind<'_>) -> Option { fn is_some(path_kind: PatKind<'_>) -> bool { match path_kind { +<<<<<<< HEAD +<<<<<<< HEAD PatKind::TupleStruct(QPath::Resolved(_, path), [first, ..], _) if is_wild(first) => { let name = path.segments[0].ident; name.name == rustc_span::sym::Some +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + PatKind::TupleStruct(QPath::Resolved(_, path), [first, ..], _) if is_wild(first) => { + let name = path.segments[0].ident; + name.name == rustc_span::sym::Some +======= + PatKind::TupleStruct(ref path_left, patterns, _) if is_wild(&patterns[0]) => match path_left { + QPath::Resolved(_, path) => { + let name = path.segments[0].ident; + if name.as_str() == "Some" { + return true; + } + return false; + }, + _ => false, +>>>>>>> 9e535f628 (fix conflict with matches macro) +======= + PatKind::TupleStruct(QPath::Resolved(_, path), patterns, _) if is_wild(&patterns[0]) => { + let name = path.segments[0].ident; + if name.name == rustc_span::sym::Some { + return true; + } + false +>>>>>>> 630f31ce5 (fix conflict with matches macro) +======= + PatKind::TupleStruct(QPath::Resolved(_, path), [first, ..], _) if is_wild(first) => { + let name = path.segments[0].ident; + name.name == rustc_span::sym::Some +>>>>>>> 342ce3da0 (fix reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + PatKind::TupleStruct(QPath::Resolved(_, path), [first, ..], _) if is_wild(first) => { + let name = path.segments[0].ident; + name.name == rustc_span::sym::Some +>>>>>>> 615b25c20 (Rebase attempt number 2) }, _ => false, } diff --git a/clippy_lints/src/matches/mod.rs b/clippy_lints/src/matches/mod.rs index d1061171e4d6..cb7c044c7b8f 100644 --- a/clippy_lints/src/matches/mod.rs +++ b/clippy_lints/src/matches/mod.rs @@ -25,7 +25,23 @@ mod wild_in_or_pats; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::source::{snippet_opt, walk_span_to_context}; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::{higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text}; +======= +use clippy_utils::{higher, in_constant, is_span_match, tokenize_with_text}; +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +use clippy_utils::{higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text}; +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::{higher, in_constant, is_direct_expn_of, is_span_match, tokenize_with_text}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat}; use rustc_lexer::TokenKind; use rustc_lint::{LateContext, LateLintPass, LintContext}; diff --git a/clippy_lints/src/matches/redundant_pattern_match.rs b/clippy_lints/src/matches/redundant_pattern_match.rs index 92e8f7dbd439..dfbf0faf6d51 100644 --- a/clippy_lints/src/matches/redundant_pattern_match.rs +++ b/clippy_lints/src/matches/redundant_pattern_match.rs @@ -119,8 +119,62 @@ fn find_sugg_for_if_let<'tcx>( let op_ty = cx.typeck_results().expr_ty(let_expr); // Determine which function should be used, and the type contained by the corresponding // variant. +<<<<<<< HEAD +<<<<<<< HEAD let Some((good_method, inner_ty)) = find_method_and_type(cx, check_pat, op_ty) else { return; +======= + let (good_method, inner_ty) = match check_pat.kind { + PatKind::TupleStruct(ref qpath, args, rest) => { + let is_wildcard = matches!(args.first().map(|p| &p.kind), Some(PatKind::Wild)); + let is_rest = matches!((args, rest.as_opt_usize()), ([], Some(_))); + + if is_wildcard || is_rest { + let res = cx.typeck_results().qpath_res(qpath, check_pat.hir_id); + let Some(id) = res.opt_def_id().map(|ctor_id| cx.tcx.parent(ctor_id)) else { return }; + let lang_items = cx.tcx.lang_items(); + if Some(id) == lang_items.result_ok_variant() { + ("is_ok()", try_get_generic_ty(op_ty, 0).unwrap_or(op_ty)) + } else if Some(id) == lang_items.result_err_variant() { + ("is_err()", try_get_generic_ty(op_ty, 1).unwrap_or(op_ty)) + } else if Some(id) == lang_items.option_some_variant() { + ("is_some()", op_ty) + } else if Some(id) == lang_items.poll_ready_variant() { + ("is_ready()", op_ty) + } else if is_pat_variant(cx, check_pat, qpath, Item::Diag(sym::IpAddr, sym!(V4))) { + ("is_ipv4()", op_ty) + } else if is_pat_variant(cx, check_pat, qpath, Item::Diag(sym::IpAddr, sym!(V6))) { + ("is_ipv6()", op_ty) + } else { + return; + } + } else { + return; + } + }, + PatKind::Path(ref path) => { + if let Res::Def(DefKind::Ctor(..), ctor_id) = cx.qpath_res(path, check_pat.hir_id) + && let Some(variant_id) = cx.tcx.opt_parent(ctor_id) + { + let method = if cx.tcx.lang_items().option_none_variant() == Some(variant_id) { + "is_none()" + } else if cx.tcx.lang_items().poll_pending_variant() == Some(variant_id) { + "is_pending()" + } else { + return; + }; + // `None` and `Pending` don't have an inner type. + (method, cx.tcx.types.unit) + } else { + return; + } + }, + _ => return, +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let Some((good_method, inner_ty)) = find_method_and_type(cx, check_pat, op_ty) else { + return; +>>>>>>> 615b25c20 (Rebase attempt number 2) }; // If this is the last expression in a block or there is an else clause then the whole @@ -204,6 +258,152 @@ pub(super) fn check_match<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, op if let Some(good_method) = found_good_method(cx, arms, node_pair) { let span = is_expn_of(expr.span, "matches").unwrap_or(expr.span.to(op.span)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let found_good_method = match node_pair { + ( + PatKind::TupleStruct(ref path_left, patterns_left, _), + PatKind::TupleStruct(ref path_right, patterns_right, _), + ) if patterns_left.len() == 1 && patterns_right.len() == 1 => { + if let (PatKind::Wild, PatKind::Wild) = (&patterns_left[0].kind, &patterns_right[0].kind) { + find_good_method_for_match( + cx, + arms, + path_left, + path_right, + Item::Lang(ResultOk), + Item::Lang(ResultErr), + "is_ok()", + "is_err()", + ) + .or_else(|| { + find_good_method_for_match( + cx, + arms, + path_left, + path_right, + Item::Diag(sym::IpAddr, sym!(V4)), + Item::Diag(sym::IpAddr, sym!(V6)), + "is_ipv4()", + "is_ipv6()", + ) + }) + } else { + None + } + }, + (PatKind::TupleStruct(ref path_left, patterns, _), PatKind::Path(ref path_right)) + | (PatKind::Path(ref path_left), PatKind::TupleStruct(ref path_right, patterns, _)) + if patterns.len() == 1 => + { + if let PatKind::Wild = patterns[0].kind { + find_good_method_for_match( + cx, + arms, + path_left, + path_right, + Item::Lang(OptionSome), + Item::Lang(OptionNone), + "is_some()", + "is_none()", + ) + .or_else(|| { + find_good_method_for_match( + cx, + arms, + path_left, + path_right, + Item::Lang(PollReady), + Item::Lang(PollPending), + "is_ready()", + "is_pending()", + ) + }) + } else { + None + } + }, + (PatKind::TupleStruct(ref path_left, patterns, _), PatKind::Wild) if patterns.len() == 1 => { + if let PatKind::Wild = patterns[0].kind { + let ident = match path_left { + QPath::Resolved(_, path) => { + let name = path.segments[0].ident; + Some(name) + }, + _ => None, + }; + if let Some(name) = ident { + match name.as_str() { + "Ok" => find_good_method_for_matches_macro( + cx, + arms, + path_left, + Item::Lang(ResultOk), + "is_ok()", + "is_err()", + ), + "Some" => find_good_method_for_matches_macro( + cx, + arms, + path_left, + Item::Lang(OptionSome), + "is_some()", + "is_none()", + ), + _ => None, + } + } else { + None + } + } else { + None + } + }, + (PatKind::Path(ref path_left), PatKind::Wild) => { + let ident = match path_left { + QPath::Resolved(_, path) => { + let name = path.segments[0].ident; + Some(name) + }, + _ => None, + }; + + if let Some(name) = ident { + match name.as_str() { + "None" => find_good_method_for_matches_macro( + cx, + arms, + path_left, + Item::Lang(OptionNone), + "is_none()", + "is_some()", + ), + _ => None, + } + } else { + None + } + }, + _ => None, + }; +======= + let found_good_method = found_good_method(cx, arms, node_pair); +>>>>>>> 630f31ce5 (fix conflict with matches macro) +======= +>>>>>>> 342ce3da0 (fix reviewer comments) + + if let Some(good_method) = found_good_method(cx, arms, node_pair) { +<<<<<<< HEAD + let span = expr.span.to(op.span); +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + let span = is_expn_of(expr.span, "matches").unwrap_or(expr.span.to(op.span)); +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let result_expr = match &op.kind { ExprKind::AddrOf(_, _, borrowed) => borrowed, _ => op, @@ -296,7 +496,39 @@ fn found_good_method<'a>( None } }, +<<<<<<< HEAD +<<<<<<< HEAD + (PatKind::Path(ref path_left), PatKind::Wild) => get_good_method(cx, arms, path_left), +======= +<<<<<<< HEAD +<<<<<<< HEAD + (PatKind::Path(ref path_left), PatKind::Wild) => get_good_method(cx, arms, path_left), +======= + (PatKind::Path(ref path_left), PatKind::Wild) => { + if let Some(name) = get_ident(path_left) { + match name.as_str() { + "None" => find_good_method_for_matches_macro( + cx, + arms, + path_left, + Item::Lang(OptionNone), + "is_none()", + "is_some()", + ), + _ => None, + } + } else { + None + } + }, +>>>>>>> 630f31ce5 (fix conflict with matches macro) +======= (PatKind::Path(ref path_left), PatKind::Wild) => get_good_method(cx, arms, path_left), +>>>>>>> fb6bf1ebf (update a func) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + (PatKind::Path(ref path_left), PatKind::Wild) => get_good_method(cx, arms, path_left), +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => None, } } @@ -317,9 +549,30 @@ fn get_good_method<'a>(cx: &LateContext<'_>, arms: &[Arm<'_>], path_left: &QPath "Ok" => { find_good_method_for_matches_macro(cx, arms, path_left, Item::Lang(ResultOk), "is_ok()", "is_err()") }, +<<<<<<< HEAD +<<<<<<< HEAD + "Err" => { + find_good_method_for_matches_macro(cx, arms, path_left, Item::Lang(ResultErr), "is_err()", "is_ok()") + }, +======= +<<<<<<< HEAD +<<<<<<< HEAD "Err" => { find_good_method_for_matches_macro(cx, arms, path_left, Item::Lang(ResultErr), "is_err()", "is_ok()") }, +======= +>>>>>>> 630f31ce5 (fix conflict with matches macro) +======= + "Err" => { + find_good_method_for_matches_macro(cx, arms, path_left, Item::Lang(ResultErr), "is_err()", "is_ok()") + }, +>>>>>>> 342ce3da0 (fix reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + "Err" => { + find_good_method_for_matches_macro(cx, arms, path_left, Item::Lang(ResultErr), "is_err()", "is_ok()") + }, +>>>>>>> 615b25c20 (Rebase attempt number 2) "Some" => find_good_method_for_matches_macro( cx, arms, @@ -328,6 +581,16 @@ fn get_good_method<'a>(cx: &LateContext<'_>, arms: &[Arm<'_>], path_left: &QPath "is_some()", "is_none()", ), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> fb6bf1ebf (update a func) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "None" => find_good_method_for_matches_macro( cx, arms, @@ -336,6 +599,17 @@ fn get_good_method<'a>(cx: &LateContext<'_>, arms: &[Arm<'_>], path_left: &QPath "is_none()", "is_some()", ), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 630f31ce5 (fix conflict with matches macro) +======= +>>>>>>> fb6bf1ebf (update a func) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => None, }; } @@ -412,6 +686,19 @@ fn find_good_method_for_match<'a>( } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +#[expect(clippy::too_many_arguments)] +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +>>>>>>> 630f31ce5 (fix conflict with matches macro) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn find_good_method_for_matches_macro<'a>( cx: &LateContext<'_>, arms: &[Arm<'_>], diff --git a/clippy_lints/src/methods/drain_collect.rs b/clippy_lints/src/methods/drain_collect.rs index 6a82d8f756ad..87d4a8b600ed 100644 --- a/clippy_lints/src/methods/drain_collect.rs +++ b/clippy_lints/src/methods/drain_collect.rs @@ -7,9 +7,24 @@ use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, Path, QPath}; use rustc_lint::LateContext; use rustc_middle::query::Key; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_middle::ty; use rustc_middle::ty::Ty; use rustc_span::{sym, Symbol}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use rustc_middle::ty; +use rustc_middle::ty::Ty; +use rustc_span::{sym, Symbol}; +<<<<<<< HEAD +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Checks if both types match the given diagnostic item, e.g.: /// @@ -51,6 +66,14 @@ fn check_collections(cx: &LateContext<'_>, expr: Ty<'_>, recv: Ty<'_>) -> Option pub(super) fn check(cx: &LateContext<'_>, args: &[Expr<'_>], expr: &Expr<'_>, recv: &Expr<'_>) { let expr_ty = cx.typeck_results().expr_ty(expr); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let recv_ty = cx.typeck_results().expr_ty(recv); let recv_ty_no_refs = recv_ty.peel_refs(); @@ -67,13 +90,67 @@ pub(super) fn check(cx: &LateContext<'_>, args: &[Expr<'_>], expr: &Expr<'_>, re format!("std::mem::take(&mut {recv})") }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + let recv_ty = cx.typeck_results().expr_ty(recv).peel_refs(); +======= + let recv_ty = cx.typeck_results().expr_ty(recv); + let recv_ty_no_refs = recv_ty.peel_refs(); +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) + + if let ExprKind::Path(QPath::Resolved(_, recv_path)) = recv.kind + && let Some(typename) = check_vec(cx, args, expr_ty, recv_ty_no_refs, recv_path) + .then_some("Vec") + .or_else(|| check_string(cx, args, expr_ty, recv_ty_no_refs, recv_path).then_some("String")) + .or_else(|| check_collections(cx, expr_ty, recv_ty_no_refs)) + { + let recv = snippet(cx, recv.span, ""); +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) span_lint_and_sugg( cx, DRAIN_COLLECT, expr.span, &format!("you seem to be trying to move all elements into a new `{typename}`"), "consider using `mem::take`", +<<<<<<< HEAD +<<<<<<< HEAD + sugg, +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + sugg, +======= + format!("std::mem::take(&mut {recv})"), +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= + match recv_ty.kind() { + ty::Ref(..) => format!("std::mem::take({recv})"), + _ => format!("std::mem::take(&mut {recv})"), +======= + if let ty::Ref(..) = recv_ty.kind() { + format!("std::mem::take({recv})") + } else { + format!("std::mem::take(&mut {recv})") +>>>>>>> 3f3657a3e (make clippy happy) + }, +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +======= + sugg, +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= sugg, +>>>>>>> 615b25c20 (Rebase attempt number 2) Applicability::MachineApplicable, ); } diff --git a/clippy_lints/src/methods/get_unwrap.rs b/clippy_lints/src/methods/get_unwrap.rs index a8f090d1de17..74413a299b4f 100644 --- a/clippy_lints/src/methods/get_unwrap.rs +++ b/clippy_lints/src/methods/get_unwrap.rs @@ -22,11 +22,45 @@ pub(super) fn check<'tcx>( let mut applicability = Applicability::MachineApplicable; let expr_ty = cx.typeck_results().expr_ty(recv); let get_args_str = snippet_with_applicability(cx, get_arg.span, "..", &mut applicability); +<<<<<<< HEAD +<<<<<<< HEAD let caller_type = if derefs_to_slice(cx, recv, expr_ty).is_some() { +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bdb2a1710 (declare needs_ref later) + let caller_type = if derefs_to_slice(cx, recv, expr_ty).is_some() { +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let caller_type = if derefs_to_slice(cx, recv, expr_ty).is_some() { +>>>>>>> 615b25c20 (Rebase attempt number 2) + "slice" + } else if is_type_diagnostic_item(cx, expr_ty, sym::Vec) { + "Vec" + } else if is_type_diagnostic_item(cx, expr_ty, sym::VecDeque) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + needs_ref = true; +======= + let mut needs_ref = true; + let caller_type = if derefs_to_slice(cx, recv, expr_ty).is_some() { +>>>>>>> 3122e3d78 (use let chains, move assignments out of block, add tests) "slice" } else if is_type_diagnostic_item(cx, expr_ty, sym::Vec) { "Vec" } else if is_type_diagnostic_item(cx, expr_ty, sym::VecDeque) { +<<<<<<< HEAD + needs_ref = true; +>>>>>>> 6331c943f (include a ref if argument is not just a numeric literal) +======= +>>>>>>> 3122e3d78 (use let chains, move assignments out of block, add tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "VecDeque" } else if !is_mut && is_type_diagnostic_item(cx, expr_ty, sym::HashMap) { "HashMap" @@ -41,7 +75,41 @@ pub(super) fn check<'tcx>( // Handle the case where the result is immediately dereferenced, // either directly be the user, or as a result of a method call or the like // by not requiring an explicit reference +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let needs_ref = if let Some(parent) = get_parent_expr(cx, expr) + && let hir::ExprKind::Unary(hir::UnOp::Deref, _) + | hir::ExprKind::MethodCall(..) + | hir::ExprKind::Field(..) + | hir::ExprKind::Index(..) = parent.kind + { + if let hir::ExprKind::Unary(hir::UnOp::Deref, _) = parent.kind { + // if the user explicitly dereferences the result, we can adjust + // the span to also include the deref part +<<<<<<< HEAD + span = parent.span; + } +======= + span = parent.span; + } + false + } else { + true + }; +<<<<<<< HEAD +======= + if needs_ref + && let Some(parent) = get_parent_expr(cx, expr) +======= let needs_ref = if let Some(parent) = get_parent_expr(cx, expr) +>>>>>>> bdb2a1710 (declare needs_ref later) && let hir::ExprKind::Unary(hir::UnOp::Deref, _) | hir::ExprKind::MethodCall(..) | hir::ExprKind::Field(..) @@ -52,10 +120,22 @@ pub(super) fn check<'tcx>( // the span to also include the deref part span = parent.span; } +<<<<<<< HEAD + needs_ref = false; + } +>>>>>>> 3122e3d78 (use let chains, move assignments out of block, add tests) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) false } else { true }; +<<<<<<< HEAD +======= +>>>>>>> bdb2a1710 (declare needs_ref later) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut_str = if is_mut { "_mut" } else { "" }; let borrow_str = if !needs_ref { diff --git a/clippy_lints/src/methods/iter_nth_zero.rs b/clippy_lints/src/methods/iter_nth_zero.rs index e1f950d5a4a5..2c9e5137afe3 100644 --- a/clippy_lints/src/methods/iter_nth_zero.rs +++ b/clippy_lints/src/methods/iter_nth_zero.rs @@ -11,6 +11,16 @@ use rustc_span::sym; use super::ITER_NTH_ZERO; pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr<'_>, arg: &hir::Expr<'_>) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let OwnerNode::Item(item) = cx.tcx.hir().owner(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) @@ -27,5 +37,31 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr format!("{}.next()", snippet_with_applicability(cx, recv.span, "..", &mut app)), app, ); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if_chain! { + if is_trait_method(cx, expr, sym::Iterator); + if let Some(Constant::Int(0)) = constant(cx, cx.typeck_results(), arg); + then { + let mut applicability = Applicability::MachineApplicable; + span_lint_and_sugg( + cx, + ITER_NTH_ZERO, + expr.span, + "called `.nth(0)` on a `std::iter::Iterator`, when `.next()` is equivalent", + "try calling `.next()` instead of `.nth(0)`", + format!("{}.next()", snippet_with_applicability(cx, recv.span, "..", &mut applicability)), + applicability, + ); + } +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } diff --git a/clippy_lints/src/methods/manual_try_fold.rs b/clippy_lints/src/methods/manual_try_fold.rs index dabed0affcf4..0ff90a34ef00 100644 --- a/clippy_lints/src/methods/manual_try_fold.rs +++ b/clippy_lints/src/methods/manual_try_fold.rs @@ -29,8 +29,28 @@ pub(super) fn check<'tcx>( && let ExprKind::Path(qpath) = path.kind && let Res::Def(DefKind::Ctor(_, _), _) = cx.qpath_res(&qpath, path.hir_id) && let ExprKind::Closure(closure) = acc.kind +<<<<<<< HEAD +<<<<<<< HEAD && !is_from_proc_macro(cx, expr) && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| snippet_opt(cx, fn_arg_span)) +======= +<<<<<<< HEAD +<<<<<<< HEAD + && !is_from_proc_macro(cx, expr) + && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| snippet_opt(cx, fn_arg_span)) +======= + && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| snippet_opt(cx, fn_arg_span)) + && !is_from_proc_macro(cx, expr) +>>>>>>> 354172a18 (New lint `manual_try_fold`) +======= + && !is_from_proc_macro(cx, expr) + && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| snippet_opt(cx, fn_arg_span)) +>>>>>>> 04b085769 (Typo) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && !is_from_proc_macro(cx, expr) + && let Some(args_snip) = closure.fn_arg_span.and_then(|fn_arg_span| snippet_opt(cx, fn_arg_span)) +>>>>>>> 615b25c20 (Rebase attempt number 2) { let init_snip = rest .is_empty() @@ -42,9 +62,34 @@ pub(super) fn check<'tcx>( cx, MANUAL_TRY_FOLD, fold_span, +<<<<<<< HEAD +<<<<<<< HEAD + "usage of `Iterator::fold` on a type that implements `Try`", + "use `try_fold` instead", + format!("try_fold({init_snip}, {args_snip} ...)", ), +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cb5d7e344 (address comments) + "usage of `Iterator::fold` on a type that implements `Try`", + "use `try_fold` instead", + format!("try_fold({init_snip}, {args_snip} ...)", ), +======= + "you seem to be using `Iterator::fold` on a type that implements `Try`", + "use `try_fold` instead", +<<<<<<< HEAD + format!("try_fold({init_snip}, {args_snip}, ...)", ), +>>>>>>> 354172a18 (New lint `manual_try_fold`) +======= + format!("try_fold({init_snip}, {args_snip} ...)", ), +>>>>>>> 04b085769 (Typo) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= "usage of `Iterator::fold` on a type that implements `Try`", "use `try_fold` instead", format!("try_fold({init_snip}, {args_snip} ...)", ), +>>>>>>> 615b25c20 (Rebase attempt number 2) Applicability::HasPlaceholders, ); } diff --git a/clippy_lints/src/methods/mod.rs b/clippy_lints/src/methods/mod.rs index d2f764dc37aa..e4f00bfcc37a 100644 --- a/clippy_lints/src/methods/mod.rs +++ b/clippy_lints/src/methods/mod.rs @@ -46,7 +46,22 @@ mod iter_overeager_cloned; mod iter_skip_next; mod iter_with_drain; mod iterator_step_by_zero; +<<<<<<< HEAD +<<<<<<< HEAD mod join_absolute_paths; +======= +<<<<<<< HEAD +<<<<<<< HEAD +mod join_absolute_path; +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= +mod join_absolute_paths; +>>>>>>> 85f4cccf4 (renamed lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +mod join_absolute_paths; +>>>>>>> 615b25c20 (Rebase attempt number 2) mod manual_next_back; mod manual_ok_or; mod manual_saturating_arithmetic; @@ -281,6 +296,14 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Checks for `.unwrap()` related calls on `Result`s and `Option`s that are constructed. /// /// ### Why is this bad? @@ -291,18 +314,98 @@ declare_clippy_lint! { /// let val1 = Some(1).unwrap(); /// let val2 = Ok::<_, ()>(1).unwrap(); /// let val3 = Err::<(), _>(1).unwrap_err(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + /// Checks for `.unwrap()` or `.unwrap_err()` calls on `Result`s and `.unwrap()` call on `Option`s. +======= + /// Checks for `.unwrap()` related calls on `Result`s and `Option`s that are constructed. +>>>>>>> 6e4c5561b (Preserve type annotations when present) + /// + /// ### Why is this bad? + /// It is better to write the value directly without the indirection. + /// + /// ### Examples + /// ```rust +<<<<<<< HEAD + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option.unwrap(); + /// result.unwrap(); +>>>>>>> e707447a8 (Boilerplate for the new lint) +======= + /// let val1 = Some(1).unwrap(); + /// let val2 = Ok::<_, ()>(1).unwrap(); + /// let val3 = Err::<(), _>(1).unwrap_err(); +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` /// /// Use instead: /// ```rust +<<<<<<< HEAD +<<<<<<< HEAD + /// let val1 = 1; + /// let val2 = 1; + /// let val3 = 1; +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// let val1 = 1; + /// let val2 = 1; + /// let val3 = 1; +======= + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option.expect("more helpful message"); + /// result.expect("more helpful message"); + /// ``` + /// + /// If [expect_used](#expect_used) is enabled, instead: + /// ```rust,ignore + /// # let option = Some(1); + /// # let result: Result = Ok(1); + /// option?; + /// + /// // or + /// + /// result?; +>>>>>>> e707447a8 (Boilerplate for the new lint) +======= /// let val1 = 1; /// let val2 = 1; /// let val3 = 1; +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// let val1 = 1; + /// let val2 = 1; + /// let val3 = 1; +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` #[clippy::version = "1.69.0"] pub UNNECESSARY_LITERAL_UNWRAP, complexity, +<<<<<<< HEAD +<<<<<<< HEAD + "using `unwrap()` related calls on `Result` and `Option` constructors" +======= +<<<<<<< HEAD +<<<<<<< HEAD + "using `unwrap()` related calls on `Result` and `Option` constructors" +======= + "checks for calls of `unwrap()` or `expect()` on `Some()` that cannot fail" +>>>>>>> e707447a8 (Boilerplate for the new lint) +======= + "using `unwrap()` related calls on `Result` and `Option` constructors" +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= "using `unwrap()` related calls on `Result` and `Option` constructors" +>>>>>>> 615b25c20 (Rebase attempt number 2) } declare_clippy_lint! { @@ -3264,7 +3367,24 @@ declare_clippy_lint! { declare_clippy_lint! { /// ### What it does +<<<<<<< HEAD +<<<<<<< HEAD /// Checks for calls to `Path::join` that start with a path separator, like `\\` or `/`.. +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 08a8a81af (Rebase and merge attempt number 2.) + /// Checks for initial `'/'` in an argument to `.join()` on a `Path`. +======= + /// Checks for initial `'/ or \\'` in an argument to `.join()` on a `Path`. +>>>>>>> 4c1b25adf (Entered supposed changes, ran cargo dev fmt, test, and bless.) +======= + /// Checks for calls to `Path::join` that start with a path separator, like `\\` or `/`.. +>>>>>>> 5e6676c1e (Added the rest of the suggested changes.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Checks for calls to `Path::join` that start with a path separator, like `\\` or `/`.. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Why is this bad? /// `.join()` arguments starting with a separator (`/` or `\\`) can replace the entire path. @@ -3295,10 +3415,42 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.70.0"] pub JOIN_ABSOLUTE_PATHS, +<<<<<<< HEAD +<<<<<<< HEAD + correctness, + "arg to .join called on a Path contains leading separator" +} + +======= +<<<<<<< HEAD + pedantic, +<<<<<<< HEAD +<<<<<<< HEAD + "arg to .join called on a Path contains '/' at the start" +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) correctness, "arg to .join called on a Path contains leading separator" } +<<<<<<< HEAD +======= +>>>>>>> 6b95029f1 (Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup) +======= +======= + "arg to .join called on a Path contains '/' at the start" +======= + "arg to .join called on a Path contains separator at the start" +>>>>>>> 5e6676c1e (Added the rest of the suggested changes.) +} + +>>>>>>> 08a8a81af (Rebase and merge attempt number 2.) +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_clippy_lint! { /// ### What it does /// Checks for `.rev().next()` on a `DoubleEndedIterator` @@ -3320,6 +3472,103 @@ declare_clippy_lint! { pub MANUAL_NEXT_BACK, style, "manual reverse iteration of `DoubleEndedIterator`" +<<<<<<< HEAD +} + +declare_clippy_lint! { + /// ### What it does + /// Checks for calls to `.drain()` that clear the collection, immediately followed by a call to `.collect()`. + /// + /// > "Collection" in this context refers to any type with a `drain` method: + /// > `Vec`, `VecDeque`, `BinaryHeap`, `HashSet`,`HashMap`, `String` + /// + /// ### Why is this bad? + /// Using `mem::take` is faster as it avoids the allocation. + /// When using `mem::take`, the old collection is replaced with an empty one and ownership of + /// the old collection is returned. + /// + /// ### Known issues + /// `mem::take(&mut vec)` is almost equivalent to `vec.drain(..).collect()`, except that + /// it also moves the **capacity**. The user might have explicitly written it this way + /// to keep the capacity on the original `Vec`. + /// + /// ### Example + /// ```rust + /// fn remove_all(v: &mut Vec) -> Vec { + /// v.drain(..).collect() + /// } + /// ``` + /// Use instead: + /// ```rust + /// use std::mem; + /// fn remove_all(v: &mut Vec) -> Vec { + /// mem::take(v) + /// } + /// ``` + #[clippy::version = "1.71.0"] + pub DRAIN_COLLECT, + perf, + "calling `.drain(..).collect()` to move all elements into a new collection" +} + +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of `Iterator::fold` with a type that implements `Try`. + /// + /// ### Why is this bad? + /// The code should use `try_fold` instead, which short-circuits on failure, thus opening the + /// door for additional optimizations not possible with `fold` as rustc can guarantee the + /// function is never called on `None`, `Err`, etc., alleviating otherwise necessary checks. It's + /// also slightly more idiomatic. + /// + /// ### Known issues + /// This lint doesn't take into account whether a function does something on the failure case, + /// i.e., whether short-circuiting will affect behavior. Refactoring to `try_fold` is not + /// desirable in those cases. + /// + /// ### Example + /// ```rust + /// vec![1, 2, 3].iter().fold(Some(0i32), |sum, i| sum?.checked_add(*i)); + /// ``` + /// Use instead: + /// ```rust + /// vec![1, 2, 3].iter().try_fold(0i32, |sum, i| sum.checked_add(*i)); + /// ``` + #[clippy::version = "1.72.0"] + pub MANUAL_TRY_FOLD, + perf, + "checks for usage of `Iterator::fold` with a type that implements `Try`" +} + +declare_clippy_lint! { + /// Looks for calls to [`Stdin::read_line`] to read a line from the standard input + /// into a string, then later attempting to parse this string into a type without first trimming it, which will + /// always fail because the string has a trailing newline in it. + /// + /// ### Why is this bad? + /// The `.parse()` call will always fail. + /// + /// ### Example + /// ```rust,ignore + /// let mut input = String::new(); + /// std::io::stdin().read_line(&mut input).expect("Failed to read a line"); + /// let num: i32 = input.parse().expect("Not a number!"); + /// assert_eq!(num, 42); // we never even get here! + /// ``` + /// Use instead: + /// ```rust,ignore + /// let mut input = String::new(); + /// std::io::stdin().read_line(&mut input).expect("Failed to read a line"); + /// let num: i32 = input.trim_end().parse().expect("Not a number!"); + /// // ^^^^^^^^^^^ remove the trailing newline + /// assert_eq!(num, 42); + /// ``` + #[clippy::version = "1.72.0"] + pub READ_LINE_WITHOUT_TRIM, + correctness, + "calling `Stdin::read_line`, then trying to parse it without first trimming" +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) } declare_clippy_lint! { @@ -3546,11 +3795,47 @@ impl_lint_pass!(Methods => [ NEEDLESS_COLLECT, SUSPICIOUS_COMMAND_ARG_SPACE, CLEAR_WITH_DRAIN, +<<<<<<< HEAD +<<<<<<< HEAD JOIN_ABSOLUTE_PATHS, MANUAL_NEXT_BACK, UNNECESSARY_LITERAL_UNWRAP, DRAIN_COLLECT, MANUAL_TRY_FOLD, +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + PATH_JOIN_CORRECTION, +======= +>>>>>>> 6b95029f1 (Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup) +======= +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + JOIN_ABSOLUTE_PATHS, + MANUAL_NEXT_BACK, + UNNECESSARY_LITERAL_UNWRAP, + DRAIN_COLLECT, + MANUAL_TRY_FOLD, +<<<<<<< HEAD +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= + UNNECESSARY_LITERAL_UNWRAP, +>>>>>>> 2902359b3 (Add the lint to the lib) +======= + DRAIN_COLLECT +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= + DRAIN_COLLECT, + MANUAL_TRY_FOLD, +>>>>>>> 354172a18 (New lint `manual_try_fold`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ]); /// Extracts a method call name, args, and `Span` of the method name. @@ -3817,12 +4102,34 @@ impl Methods { Some(("err", recv, [], err_span, _)) => err_expect::check(cx, expr, recv, span, err_span, &self.msrv), _ => expect_used::check(cx, expr, recv, false, self.allow_expect_in_tests), } +<<<<<<< HEAD +<<<<<<< HEAD unnecessary_literal_unwrap::check(cx, expr, recv, name, args); }, ("expect_err", [_]) => { unnecessary_literal_unwrap::check(cx, expr, recv, name, args); expect_used::check(cx, expr, recv, true, self.allow_expect_in_tests); }, +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); + }, + ("expect_err", [_]) => { + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); + expect_used::check(cx, expr, recv, true, self.allow_expect_in_tests); + }, +<<<<<<< HEAD +>>>>>>> 69af0e13b (Recognize `Err`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ("extend", [arg]) => { string_extend_chars::check(cx, expr, recv, arg); extend_with_drain::check(cx, expr, recv, arg); @@ -4039,7 +4346,28 @@ impl Methods { }, _ => {}, } +<<<<<<< HEAD +<<<<<<< HEAD + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +======= + if let ExprKind::Call(recv, _) = recv.kind { + unnecessary_literal_unwrap::check(cx, expr, recv, name); +======= + if let ExprKind::Call(recv, [arg]) = recv.kind { + unnecessary_literal_unwrap::check(cx, expr, recv, arg, name); +>>>>>>> daf619748 (Implement the suggestion) + } +>>>>>>> 0b1bb5fbf (Implement the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +>>>>>>> 615b25c20 (Rebase attempt number 2) unwrap_used::check(cx, expr, recv, false, self.allow_unwrap_in_tests); }, ("unwrap_err", []) => { @@ -4074,6 +4402,66 @@ impl Methods { }, } unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + unnecessary_literal_unwrap::check(cx, expr, recv, name); +======= + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +>>>>>>> 6e4dc93e2 (Support suggesting panics) + unwrap_used::check(cx, expr, recv, false, self.allow_unwrap_in_tests); + }, + ("unwrap_err", []) => { + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); + unwrap_used::check(cx, expr, recv, true, self.allow_unwrap_in_tests); + }, + ("unwrap_or", [u_arg]) => { + match method_call(recv) { + Some((arith @ ("checked_add" | "checked_sub" | "checked_mul"), lhs, [rhs], _, _)) => { + manual_saturating_arithmetic::check(cx, expr, lhs, rhs, u_arg, &arith["checked_".len()..]); + }, + Some(("map", m_recv, [m_arg], span, _)) => { + option_map_unwrap_or::check(cx, expr, m_recv, m_arg, recv, u_arg, span, &self.msrv); + }, + Some(("then_some", t_recv, [t_arg], _, _)) => { + obfuscated_if_else::check(cx, expr, t_recv, t_arg, u_arg); + }, + _ => {}, + } + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); + }, + ("unwrap_or_default", []) => { + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); + } +<<<<<<< HEAD + ("unwrap_or_else", [u_arg]) => match method_call(recv) { + Some(("map", recv, [map_arg], _, _)) + if map_unwrap_or::check(cx, expr, recv, map_arg, u_arg, &self.msrv) => {}, + _ => { + unwrap_or_else_default::check(cx, expr, recv, u_arg); + unnecessary_lazy_eval::check(cx, expr, recv, u_arg, "unwrap_or"); + }, +>>>>>>> 8f8350298 (Recognize `unwrap_or` methods) +======= + ("unwrap_or_else", [u_arg]) => { + match method_call(recv) { + Some(("map", recv, [map_arg], _, _)) + if map_unwrap_or::check(cx, expr, recv, map_arg, u_arg, &self.msrv) => {}, + _ => { + unwrap_or_else_default::check(cx, expr, recv, u_arg); + unnecessary_lazy_eval::check(cx, expr, recv, u_arg, "unwrap_or"); + }, + } +<<<<<<< HEAD + unnecessary_literal_unwrap::check(cx, expr, recv, name); +>>>>>>> 7ed7283e0 (Recognize `unwrap_or_else` method) +======= + unnecessary_literal_unwrap::check(cx, expr, recv, name, args); +>>>>>>> 6e4dc93e2 (Support suggesting panics) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }, ("zip", [arg]) => { if let ExprKind::MethodCall(name, iter_recv, [], _) = recv.kind diff --git a/clippy_lints/src/methods/needless_collect.rs b/clippy_lints/src/methods/needless_collect.rs index 9df268c437db..8fd58699dd63 100644 --- a/clippy_lints/src/methods/needless_collect.rs +++ b/clippy_lints/src/methods/needless_collect.rs @@ -16,6 +16,16 @@ use rustc_hir::{ use rustc_lint::LateContext; use rustc_middle::hir::nested_filter; use rustc_middle::ty::{self, AssocKind, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty}; +<<<<<<< HEAD +======= +<<<<<<< HEAD +use rustc_middle::ty::{self, AssocKind, ClauseKind, EarlyBinder, GenericArg, GenericArgKind, Ty}; +======= +use rustc_middle::ty::{self, AssocKind, Clause, EarlyBinder, GenericArg, GenericArgKind, PredicateKind, Ty}; +>>>>>>> 84f89f30e (enhance `needless_collect`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_span::symbol::Ident; use rustc_span::{sym, Span, Symbol}; @@ -175,6 +185,16 @@ fn check_collect_into_intoiterator<'tcx>( .into_iter() .filter_map(|p| { if let ClauseKind::Trait(t) = p.kind().skip_binder() +<<<<<<< HEAD +======= +<<<<<<< HEAD + if let ClauseKind::Trait(t) = p.kind().skip_binder() +======= + if let PredicateKind::Clause(Clause::Trait(t)) = p.kind().skip_binder() +>>>>>>> 84f89f30e (enhance `needless_collect`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && cx.tcx.is_diagnostic_item(sym::IntoIterator,t.trait_ref.def_id) { Some(t.self_ty()) } else { diff --git a/clippy_lints/src/methods/option_map_unwrap_or.rs b/clippy_lints/src/methods/option_map_unwrap_or.rs index fcbe005fb286..25a1223a21a2 100644 --- a/clippy_lints/src/methods/option_map_unwrap_or.rs +++ b/clippy_lints/src/methods/option_map_unwrap_or.rs @@ -72,10 +72,40 @@ pub(super) fn check<'tcx>( return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a693cbc1b (changed msrv name for consistency & changed nested if for style) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // is_some_and is stabilised && `unwrap_or` argument is false; suggest `is_some_and` instead let suggest_is_some_and = msrv.meets(msrvs::OPTION_IS_SOME_AND) && matches!(&unwrap_arg.kind, ExprKind::Lit(lit) if matches!(lit.node, rustc_ast::LitKind::Bool(false))); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + let mut suggest_is_some_and = false; + // argument to `unwrap_or` is false & is_some_and is stabilised; should suggest using `is_some_and` + if msrv.meets(msrvs::OPT_IS_SOME_AND) { + if let ExprKind::Lit(unwrap_lit) = &unwrap_arg.kind { + if let rustc_ast::LitKind::Bool(false) = unwrap_lit.node { + suggest_is_some_and = true; + } + } + } +>>>>>>> 9b7d8d1dc (suggests `is_some_and` over `map().unwrap_or(false)`) +======= +>>>>>>> a693cbc1b (changed msrv name for consistency & changed nested if for style) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut applicability = Applicability::MachineApplicable; // get snippet for unwrap_or() diff --git a/clippy_lints/src/methods/unnecessary_fold.rs b/clippy_lints/src/methods/unnecessary_fold.rs index 6e23754bf46e..de74469bd1ea 100644 --- a/clippy_lints/src/methods/unnecessary_fold.rs +++ b/clippy_lints/src/methods/unnecessary_fold.rs @@ -13,10 +13,39 @@ use rustc_span::sym; use super::UNNECESSARY_FOLD; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Do we need to suggest turbofish when suggesting a replacement method? /// Changing `fold` to `sum` needs it sometimes when the return type can't be /// inferred. This checks for some common cases where it can be safely omitted fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +/// No turbofish needed in any case. +fn no_turbofish(_: &LateContext<'_>, _: &hir::Expr<'_>) -> bool { + false +} + +/// Turbofish (`::`) may be needed, but can be omitted if we are certain +/// that the type can be inferred from usage. +fn turbofish_if_not_inferred(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let parent = cx.tcx.hir().get_parent(expr.hir_id); // some common cases where turbofish isn't needed: @@ -50,6 +79,14 @@ fn needs_turbofish(cx: &LateContext<'_>, expr: &hir::Expr<'_>) -> bool { struct Replacement { method_name: &'static str, has_args: bool, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) has_generic_return: bool, } @@ -111,8 +148,46 @@ fn check_fold_with_op( sugg, applicability, ); +<<<<<<< HEAD +<<<<<<< HEAD + } + } +======= +<<<<<<< HEAD +======= + requires_turbofish: fn(&LateContext<'_>, &hir::Expr<'_>) -> bool, +} +impl Replacement { + /// `any(f)`, `all(f)` + pub fn non_generic(method_name: &'static str) -> Self { + Self { + method_name, + has_args: true, + requires_turbofish: no_turbofish, + } + } + + /// `sum::()`, `product::()` + pub fn generic(method_name: &'static str) -> Self { + Self { + method_name, + has_args: false, + requires_turbofish: turbofish_if_not_inferred, +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) + } + } +======= + has_generic_return: bool, +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +======= + } + } +>>>>>>> d102e2296 (move check_fold_with_op function out) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= } } +>>>>>>> 615b25c20 (Rebase attempt number 2) } pub(super) fn check( @@ -122,6 +197,80 @@ pub(super) fn check( acc: &hir::Expr<'_>, fold_span: Span, ) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + fn check_fold_with_op( + cx: &LateContext<'_>, + expr: &hir::Expr<'_>, + acc: &hir::Expr<'_>, + fold_span: Span, + op: hir::BinOpKind, + replacement: Replacement, + ) { + if_chain! { + // Extract the body of the closure passed to fold + if let hir::ExprKind::Closure(&hir::Closure { body, .. }) = acc.kind; + let closure_body = cx.tcx.hir().body(body); + let closure_expr = peel_blocks(closure_body.value); + + // Check if the closure body is of the form `acc some_expr(x)` + if let hir::ExprKind::Binary(ref bin_op, left_expr, right_expr) = closure_expr.kind; + if bin_op.node == op; + + // Extract the names of the two arguments to the closure + if let [param_a, param_b] = closure_body.params; + if let PatKind::Binding(_, first_arg_id, ..) = strip_pat_refs(param_a.pat).kind; + if let PatKind::Binding(_, second_arg_id, second_arg_ident, _) = strip_pat_refs(param_b.pat).kind; + + if path_to_local_id(left_expr, first_arg_id); + if replacement.has_args || path_to_local_id(right_expr, second_arg_id); + + then { + let mut applicability = Applicability::MachineApplicable; + + let turbofish = if replacement.has_generic_return { + format!("::<{}>", cx.typeck_results().expr_ty_adjusted(right_expr).peel_refs()) + } else { + String::new() + }; + + let sugg = if replacement.has_args { + format!( + "{method}{turbofish}(|{second_arg_ident}| {r})", + method = replacement.method_name, + r = snippet_with_applicability(cx, right_expr.span, "EXPR", &mut applicability), + ) + } else { + format!( + "{method}{turbofish}()", + method = replacement.method_name, + ) + }; + + span_lint_and_sugg( + cx, + UNNECESSARY_FOLD, + fold_span.with_hi(expr.span.hi()), + // TODO #2371 don't suggest e.g., .any(|x| f(x)) if we can suggest .any(f) + "this `.fold` can be written more succinctly using another method", + "try", + sugg, + applicability, + ); + } + } + } + +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> d102e2296 (move check_fold_with_op function out) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Check that this is a call to Iterator::fold rather than just some function called fold if !is_trait_method(cx, expr, sym::Iterator) { return; @@ -137,11 +286,33 @@ pub(super) fn check( acc, fold_span, hir::BinOpKind::Or, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Replacement { has_args: true, has_generic_return: false, method_name: "any", }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Replacement::non_generic("any"), +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ); }, ast::LitKind::Bool(true) => { @@ -151,11 +322,33 @@ pub(super) fn check( acc, fold_span, hir::BinOpKind::And, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Replacement { has_args: true, has_generic_return: false, method_name: "all", }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Replacement::non_generic("all"), +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ); }, ast::LitKind::Int(0, _) => check_fold_with_op( @@ -164,11 +357,33 @@ pub(super) fn check( acc, fold_span, hir::BinOpKind::Add, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Replacement { has_args: false, has_generic_return: needs_turbofish(cx, expr), method_name: "sum", }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Replacement::generic("sum"), +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ), ast::LitKind::Int(1, _) => { check_fold_with_op( @@ -177,11 +392,33 @@ pub(super) fn check( acc, fold_span, hir::BinOpKind::Mul, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Replacement { has_args: false, has_generic_return: needs_turbofish(cx, expr), method_name: "product", }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Replacement::generic("product"), +>>>>>>> c9daec258 ([`unnecessary_fold`]: suggest turbofish if necessary) +======= +>>>>>>> 69e892e3a (get rid of unnecessary function pointer) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ); }, _ => (), diff --git a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs index 111bcaaecec3..2862628fb87c 100644 --- a/clippy_lints/src/methods/unnecessary_literal_unwrap.rs +++ b/clippy_lints/src/methods/unnecessary_literal_unwrap.rs @@ -1,5 +1,23 @@ +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::{is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{diagnostics::span_lint_and_then, is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +======= +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::{is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::{is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_errors::Applicability; use rustc_hir as hir; use rustc_lint::LateContext; @@ -114,4 +132,126 @@ pub(super) fn check( }, } }); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::ty::is_type_diagnostic_item; +======= +use clippy_utils::{diagnostics::span_lint_and_help, is_res_lang_ctor, path_res}; +>>>>>>> 0b1bb5fbf (Implement the lint) +======= +use clippy_utils::{diagnostics::span_lint_and_then, is_res_lang_ctor, path_res}; +======= +use clippy_utils::{diagnostics::span_lint_and_then, is_res_lang_ctor, last_path_segment, path_res, MaybePath}; +>>>>>>> 6e4c5561b (Preserve type annotations when present) +use rustc_errors::Applicability; +>>>>>>> daf619748 (Implement the suggestion) +use rustc_hir as hir; +use rustc_lint::LateContext; + +use super::UNNECESSARY_LITERAL_UNWRAP; + +fn get_ty_from_args<'a>(args: Option<&'a [hir::GenericArg<'a>]>, index: usize) -> Option<&'a hir::Ty<'a>> { + let args = args?; + + if args.len() <= index { + return None; + } + + match args[index] { + hir::GenericArg::Type(ty) => match ty.kind { + hir::TyKind::Infer => None, + _ => Some(ty), + }, + _ => None, + } +} + +pub(super) fn check( + cx: &LateContext<'_>, + expr: &hir::Expr<'_>, + recv: &hir::Expr<'_>, + method: &str, + args: &[hir::Expr<'_>], +) { + let init = clippy_utils::expr_or_init(cx, recv); + + let (constructor, call_args, ty) = if let hir::ExprKind::Call(call, call_args) = init.kind { + let Some(qpath) = call.qpath_opt() else { return }; + + let args = last_path_segment(qpath).args.map(|args| args.args); + let res = cx.qpath_res(qpath, call.hir_id()); + + if is_res_lang_ctor(cx, res, hir::LangItem::OptionSome) { + ("Some", call_args, get_ty_from_args(args, 0)) + } else if is_res_lang_ctor(cx, res, hir::LangItem::ResultOk) { + ("Ok", call_args, get_ty_from_args(args, 0)) + } else if is_res_lang_ctor(cx, res, hir::LangItem::ResultErr) { + ("Err", call_args, get_ty_from_args(args, 1)) + } else { + return; + } + } else if is_res_lang_ctor(cx, path_res(cx, init), hir::LangItem::OptionNone) { + let call_args: &[hir::Expr<'_>] = &[]; + ("None", call_args, None) + } else { + return; + }; + + let help_message = format!("used `{method}()` on `{constructor}` value"); + let suggestion_message = format!("remove the `{constructor}` and `{method}()`"); + + span_lint_and_then(cx, UNNECESSARY_LITERAL_UNWRAP, expr.span, &help_message, |diag| { + let suggestions = match (constructor, method, ty) { + ("None", "unwrap", _) => Some(vec![(expr.span, "panic!()".to_string())]), + ("None", "expect", _) => Some(vec![ + (expr.span.with_hi(args[0].span.lo()), "panic!(".to_string()), + (expr.span.with_lo(args[0].span.hi()), ")".to_string()), + ]), + (_, _, Some(_)) => None, + ("Ok", "unwrap_err", None) | ("Err", "unwrap", None) => Some(vec![ + ( + recv.span.with_hi(call_args[0].span.lo()), + "panic!(\"{:?}\", ".to_string(), + ), + (expr.span.with_lo(call_args[0].span.hi()), ")".to_string()), + ]), + ("Ok", "expect_err", None) | ("Err", "expect", None) => Some(vec![ + ( + recv.span.with_hi(call_args[0].span.lo()), + "panic!(\"{1}: {:?}\", ".to_string(), + ), + (call_args[0].span.with_lo(args[0].span.lo()), ", ".to_string()), + ]), + (_, _, None) => Some(vec![ + (recv.span.with_hi(call_args[0].span.lo()), String::new()), + (expr.span.with_lo(call_args[0].span.hi()), String::new()), + ]), + }; + +<<<<<<< HEAD + diag.multipart_suggestion(suggestion_message, suggestions, Applicability::MachineApplicable); + }); + } else { + span_lint_and_then(cx, UNNECESSARY_LITERAL_UNWRAP, expr.span, &help_message, |diag| { + diag.span_help(init.span, suggestion_message); + }); + } +>>>>>>> e707447a8 (Boilerplate for the new lint) +======= + match (init.span == recv.span, suggestions) { + (true, Some(suggestions)) => { + diag.multipart_suggestion(suggestion_message, suggestions, Applicability::MachineApplicable); + }, + _ => { + diag.span_help(init.span, suggestion_message); + }, + } + }); +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/clippy_lints/src/min_ident_chars.rs b/clippy_lints/src/min_ident_chars.rs index 2a60f2faca0a..5e8ada4f8f0b 100644 --- a/clippy_lints/src/min_ident_chars.rs +++ b/clippy_lints/src/min_ident_chars.rs @@ -1,6 +1,8 @@ use clippy_utils::diagnostics::span_lint; use clippy_utils::is_from_proc_macro; use rustc_data_structures::fx::FxHashSet; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_hir::def::{DefKind, Res}; use rustc_hir::intravisit::{walk_item, Visitor}; use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind}; @@ -8,6 +10,40 @@ use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; +======= +<<<<<<< HEAD +use rustc_hir::{ + def::{DefKind, Res}, + intravisit::{walk_item, Visitor}, +<<<<<<< HEAD +<<<<<<< HEAD + GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, +======= + GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind, +>>>>>>> 243943ff5 (make it work for locals as well) +}; +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use rustc_hir::def::{DefKind, Res}; +use rustc_hir::intravisit::{walk_item, Visitor}; +use rustc_hir::{GenericParamKind, HirId, Item, ItemKind, ItemLocalId, Node, Pat, PatKind}; +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_middle::lint::in_external_macro; +use rustc_session::{declare_tool_lint, impl_lint_pass}; +use rustc_span::Span; +<<<<<<< HEAD +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +use rustc_span::Span; +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::borrow::Cow; declare_clippy_lint! { @@ -33,6 +69,19 @@ declare_clippy_lint! { /// let title = movie.title; /// } /// ``` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + /// ``` +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 29c1c6e10 (refactor and add link to issue) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::version = "1.72.0"] pub MIN_IDENT_CHARS, restriction, @@ -46,6 +95,16 @@ pub struct MinIdentChars { pub min_ident_chars_threshold: u64, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 29c1c6e10 (refactor and add link to issue) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl MinIdentChars { #[expect(clippy::cast_possible_truncation)] fn is_ident_too_short(&self, cx: &LateContext<'_>, str: &str, span: Span) -> bool { @@ -57,6 +116,17 @@ impl MinIdentChars { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 29c1c6e10 (refactor and add link to issue) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl LateLintPass<'_> for MinIdentChars { fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) { if self.min_ident_chars_threshold == 0 { @@ -65,6 +135,30 @@ impl LateLintPass<'_> for MinIdentChars { walk_item(&mut IdentVisitor { conf: self, cx }, item); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + + // This is necessary as `Node::Pat`s are not visited in `visit_id`. :/ + fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { + if let PatKind::Binding(_, _, ident, ..) = pat.kind + && let str = ident.as_str() + && self.is_ident_too_short(cx, str, ident.span) + { + emit_min_ident_chars(self, cx, str, ident.span); + } + } +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= // This is necessary as `Node::Pat`s are not visited in `visit_id`. :/ fn check_pat(&mut self, cx: &LateContext<'_>, pat: &Pat<'_>) { @@ -75,6 +169,10 @@ impl LateLintPass<'_> for MinIdentChars { emit_min_ident_chars(self, cx, str, ident.span); } } +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } struct IdentVisitor<'cx, 'tcx> { @@ -82,12 +180,43 @@ struct IdentVisitor<'cx, 'tcx> { cx: &'cx LateContext<'tcx>, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl Visitor<'_> for IdentVisitor<'_, '_> { fn visit_id(&mut self, hir_id: HirId) { let Self { conf, cx } = *self; // FIXME(#112534) Reimplementation of `find`, as it uses indexing, which can (and will in // async functions, or really anything async) panic. This should probably be fixed on the // rustc side, this is just a temporary workaround. +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +#[expect(clippy::cast_possible_truncation)] +======= +>>>>>>> 243943ff5 (make it work for locals as well) +impl Visitor<'_> for IdentVisitor<'_, '_> { + fn visit_id(&mut self, hir_id: HirId) { + let Self { conf, cx } = *self; +<<<<<<< HEAD + // Reimplementation of `find`, as it uses indexing, which can (and will in async functions) panic. + // This should probably be fixed on the rustc side, this is just a temporary workaround. + // FIXME: Remove me if/when this is fixed in rustc +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + // FIXME(#112534) Reimplementation of `find`, as it uses indexing, which can (and will in + // async functions, or really anything async) panic. This should probably be fixed on the + // rustc side, this is just a temporary workaround. +>>>>>>> 29c1c6e10 (refactor and add link to issue) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let node = if hir_id.local_id == ItemLocalId::from_u32(0) { // In this case, we can just use `find`, `Owner`'s `node` field is private anyway so we can't // reimplement it even if we wanted to @@ -106,7 +235,28 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { }; let str = ident.as_str(); +<<<<<<< HEAD +<<<<<<< HEAD + if conf.is_ident_too_short(cx, str, ident.span) { +======= +<<<<<<< HEAD +<<<<<<< HEAD if conf.is_ident_too_short(cx, str, ident.span) { +======= + if !in_external_macro(cx.sess(), ident.span) + && str.len() <= conf.min_ident_chars_threshold as usize + && !str.starts_with('_') + && !str.is_empty() + && conf.allowed_idents_below_min_chars.get(&str.to_owned()).is_none() + { +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + if conf.is_ident_too_short(cx, str, ident.span) { +>>>>>>> 29c1c6e10 (refactor and add link to issue) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if conf.is_ident_too_short(cx, str, ident.span) { +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Node::Item(item) = node && let ItemKind::Use(..) = item.kind { return; } @@ -133,6 +283,50 @@ impl Visitor<'_> for IdentVisitor<'_, '_> { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + emit_min_ident_chars(conf, cx, str, ident.span); + } + } +} + +fn emit_min_ident_chars(conf: &MinIdentChars, cx: &impl LintContext, ident: &str, span: Span) { + let help = if conf.min_ident_chars_threshold == 1 { + Cow::Borrowed("this ident consists of a single char") + } else { + Cow::Owned(format!( + "this ident is too short ({} <= {})", + ident.len(), + conf.min_ident_chars_threshold, + )) + }; + span_lint(cx, MIN_IDENT_CHARS, span, &help); +} +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let help = if conf.min_ident_chars_threshold == 1 { + Cow::Borrowed("this ident consists of a single char") + } else { + Cow::Owned(format!( + "this ident is too short ({} <= {})", + str.len(), + conf.min_ident_chars_threshold, + )) + }; + span_lint(cx, MIN_IDENT_CHARS, ident.span, &help); + } + } +} +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= emit_min_ident_chars(conf, cx, str, ident.span); } } @@ -150,3 +344,7 @@ fn emit_min_ident_chars(conf: &MinIdentChars, cx: &impl LintContext, ident: &str }; span_lint(cx, MIN_IDENT_CHARS, span, &help); } +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/clippy_lints/src/misc_early/mod.rs b/clippy_lints/src/misc_early/mod.rs index b226b8781237..433ce3067ac1 100644 --- a/clippy_lints/src/misc_early/mod.rs +++ b/clippy_lints/src/misc_early/mod.rs @@ -340,11 +340,36 @@ declare_clippy_lint! { /// // NOTE: Type is a `Vec` here /// println!("all elements: {all:#?}"); /// } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3376c714e (Add note to remove `if` statement altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// // or /// println!("all elements: {v:#?}"); /// ``` #[clippy::version = "1.72.0"] pub REDUNDANT_AT_REST_PATTERN, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + /// ``` + #[clippy::version = "1.72.0"] +<<<<<<< HEAD + pub REDUNDANT_REST_PATTERN, +>>>>>>> 9a8347ded (New lint [`redundant_rest_pattern`]) +======= + pub REDUNDANT_AT_REST_PATTERN, +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) complexity, "checks for `[all @ ..]` where `all` would suffice" } @@ -360,7 +385,23 @@ declare_lint_pass!(MiscEarlyLints => [ BUILTIN_TYPE_SHADOW, REDUNDANT_PATTERN, UNNEEDED_WILDCARD_PATTERN, +<<<<<<< HEAD +<<<<<<< HEAD + REDUNDANT_AT_REST_PATTERN, +======= +<<<<<<< HEAD +<<<<<<< HEAD + REDUNDANT_AT_REST_PATTERN, +======= + REDUNDANT_REST_PATTERN, +>>>>>>> 9a8347ded (New lint [`redundant_rest_pattern`]) +======= REDUNDANT_AT_REST_PATTERN, +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + REDUNDANT_AT_REST_PATTERN, +>>>>>>> 615b25c20 (Rebase attempt number 2) ]); impl EarlyLintPass for MiscEarlyLints { @@ -377,7 +418,23 @@ impl EarlyLintPass for MiscEarlyLints { unneeded_field_pattern::check(cx, pat); redundant_pattern::check(cx, pat); +<<<<<<< HEAD +<<<<<<< HEAD + redundant_at_rest_pattern::check(cx, pat); +======= +<<<<<<< HEAD +<<<<<<< HEAD + redundant_at_rest_pattern::check(cx, pat); +======= + redundant_rest_pattern::check(cx, pat); +>>>>>>> 9a8347ded (New lint [`redundant_rest_pattern`]) +======= + redundant_at_rest_pattern::check(cx, pat); +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= redundant_at_rest_pattern::check(cx, pat); +>>>>>>> 615b25c20 (Rebase attempt number 2) unneeded_wildcard_pattern::check(cx, pat); } diff --git a/clippy_lints/src/missing_fields_in_debug.rs b/clippy_lints/src/missing_fields_in_debug.rs index 2f63b9b9f0b8..d29da6995cc8 100644 --- a/clippy_lints/src/missing_fields_in_debug.rs +++ b/clippy_lints/src/missing_fields_in_debug.rs @@ -1,5 +1,32 @@ use std::ops::ControlFlow; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +use clippy_utils::{ + diagnostics::span_lint_and_then, +<<<<<<< HEAD +<<<<<<< HEAD + is_path_lang_item, paths, +======= + paths, +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= + is_path_lang_item, paths, +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) + ty::match_type, + visitors::{for_each_expr, Visitable}, +}; +use rustc_ast::LitKind; +use rustc_data_structures::fx::FxHashSet; +<<<<<<< HEAD +<<<<<<< HEAD +use rustc_hir::Block; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::ty::match_type; use clippy_utils::visitors::{for_each_expr, Visitable}; @@ -7,11 +34,49 @@ use clippy_utils::{is_path_lang_item, paths}; use rustc_ast::LitKind; use rustc_data_structures::fx::FxHashSet; use rustc_hir::def::{DefKind, Res}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{ Block, Expr, ExprKind, Impl, ImplItem, ImplItemKind, Item, ItemKind, LangItem, Node, QPath, TyKind, VariantData, }; use rustc_lint::{LateContext, LateLintPass}; +<<<<<<< HEAD +<<<<<<< HEAD +use rustc_middle::ty::{Ty, TypeckResults}; +======= +<<<<<<< HEAD +use rustc_middle::ty::Ty; +use rustc_middle::ty::TypeckResults; +======= +======= +use rustc_hir::Block; +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +use rustc_hir::{ + def::{DefKind, Res}, + Expr, ImplItemKind, LangItem, Node, +}; +use rustc_hir::{ExprKind, Impl, ItemKind, QPath, TyKind}; +use rustc_hir::{ImplItem, Item, VariantData}; +use rustc_lint::{LateContext, LateLintPass}; +use rustc_middle::ty::Ty; +use rustc_middle::ty::TypeckResults; +<<<<<<< HEAD +use rustc_middle::ty::{EarlyBinder, Ty}; +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +======= use rustc_middle::ty::{Ty, TypeckResults}; +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_middle::ty::{Ty, TypeckResults}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, Span, Symbol}; @@ -32,12 +97,41 @@ declare_clippy_lint! { /// Oftentimes there is more logic to a `Debug` impl if it uses `write!` macro, so it tries /// to be on the conservative side and not lint in those cases in an attempt to prevent false positives. /// +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + /// This lint also does not look through function calls, so calling a function does not consider fields + /// used inside of that function as used by the `Debug` impl. + /// + /// Lastly, it also ignores tuple structs as their `DebugTuple` formatter does not have a `finish_non_exhaustive` + /// method, as well as enums because their exhaustiveness is already checked by the compiler when matching on the enum, + /// making it much less likely to accidentally forget to update the `Debug` impl when adding a new variant. +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + /// This lint also does not look through function calls, so calling `.field(self.as_slice())` for example + /// does not consider fields used inside of `as_slice()` as used by the `Debug` impl. + /// + /// Lastly, it also ignores tuple structs as their `DebugTuple` formatter does not have a `finish_non_exhaustive` + /// method. +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= /// This lint also does not look through function calls, so calling a function does not consider fields /// used inside of that function as used by the `Debug` impl. /// /// Lastly, it also ignores tuple structs as their `DebugTuple` formatter does not have a `finish_non_exhaustive` /// method, as well as enums because their exhaustiveness is already checked by the compiler when matching on the enum, /// making it much less likely to accidentally forget to update the `Debug` impl when adding a new variant. +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Example /// ```rust @@ -180,7 +274,24 @@ fn check_struct<'tcx>( .fields() .iter() .filter_map(|field| { +<<<<<<< HEAD +<<<<<<< HEAD + if field_accesses.contains(&field.ident.name) || is_path_lang_item(cx, field.ty, LangItem::PhantomData) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + if field_accesses.contains(&field.ident.name) || is_path_lang_item(cx, field.ty, LangItem::PhantomData) { +======= + let EarlyBinder(field_ty) = cx.tcx.type_of(field.def_id); + if field_accesses.contains(&field.ident.name) || field_ty.is_phantom_data() { +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= if field_accesses.contains(&field.ident.name) || is_path_lang_item(cx, field.ty, LangItem::PhantomData) { +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if field_accesses.contains(&field.ident.name) || is_path_lang_item(cx, field.ty, LangItem::PhantomData) { +>>>>>>> 615b25c20 (Rebase attempt number 2) None } else { Some((field.span, "this field is unused")) @@ -195,16 +306,133 @@ fn check_struct<'tcx>( } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +/// Attempts to find unused fields in variants assuming that +/// the item is an enum. +/// +/// Currently, only simple cases are detected where the user +/// matches on `self` and calls `debug_struct` inside of the arms +fn check_enum<'tcx>( + cx: &LateContext<'tcx>, + typeck_results: &TypeckResults<'tcx>, + block: &'tcx Block<'tcx>, + self_ty: Ty<'tcx>, + item: &'tcx Item<'tcx>, +) { + let Some(arms) = for_each_expr(block, |expr| { + if let ExprKind::Match(val, arms, MatchSource::Normal) = expr.kind + && let match_ty = typeck_results.expr_ty_adjusted(val).peel_refs() + && match_ty == self_ty + { + ControlFlow::Break(arms) + } else { + ControlFlow::Continue(()) + } + }) else { + return; + }; + + let mut span_notes = Vec::new(); + + for arm in arms { + if !should_lint(cx, typeck_results, arm.body) { + continue; + } + + arm.pat.walk_always(|pat| match pat.kind { + PatKind::Wild => span_notes.push((pat.span, "unused field here due to wildcard `_`")), + PatKind::Tuple(_, rest) | PatKind::TupleStruct(.., rest) if rest.as_opt_usize().is_some() => { + span_notes.push((pat.span, "more unused fields here due to rest pattern `..`")); + }, + PatKind::Struct(.., true) => { + span_notes.push((pat.span, "more unused fields here due to rest pattern `..`")); + }, + _ => {}, + }); + + let mut field_accesses = FxHashSet::default(); + let mut check_field_access = |sym, expr| { + if !typeck_results.expr_ty(expr).is_phantom_data() { + arm.pat.each_binding(|_, _, _, pat_ident| { + if sym == pat_ident.name { + field_accesses.insert(pat_ident); + } + }); + } + }; + + for_each_expr(arm.body, |expr| { + if let ExprKind::Path(QPath::Resolved(_, path)) = expr.kind && let Some(segment) = path.segments.first() + { + check_field_access(segment.ident.name, expr); + } else if let Some(sym) = as_field_call(cx, typeck_results, expr) { + check_field_access(sym, expr); + } + ControlFlow::::Continue(()) + }); + + arm.pat.each_binding(|_, _, span, pat_ident| { + if !field_accesses.contains(&pat_ident) { + span_notes.push((span, "the field referenced by this binding is unused")); + } + }); + } + + if !span_notes.is_empty() { + report_lints(cx, item.span, span_notes); + } +} + +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug { fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx rustc_hir::Item<'tcx>) { // is this an `impl Debug for X` block? if let ItemKind::Impl(Impl { of_trait: Some(trait_ref), self_ty, items, .. }) = item.kind && let Res::Def(DefKind::Trait, trait_def_id) = trait_ref.path.res && let TyKind::Path(QPath::Resolved(_, self_path)) = &self_ty.kind +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 1cf95a9d5 (don't call `type_of` on generic params) + // don't trigger if self is a generic parameter, e.g. `impl Debug for T` + // this can only happen in core itself, where the trait is defined, + // but it caused ICEs in the past: + // /~https://github.com/rust-lang/rust-clippy/issues/10887 + && !matches!(self_path.res, Res::Def(DefKind::TyParam, _)) +<<<<<<< HEAD +======= +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +>>>>>>> 1cf95a9d5 (don't call `type_of` on generic params) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // make sure that the self type is either a struct, an enum or a union // this prevents ICEs such as when self is a type parameter or a primitive type // (see #10887, #11063) && let Res::Def(DefKind::Struct | DefKind::Enum | DefKind::Union, self_path_did) = self_path.res +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 555ceb83f ([`missing_fields_in_debug`]: make sure `self` is an adt) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && cx.match_def_path(trait_def_id, &[sym::core, sym::fmt, sym::Debug]) // don't trigger if this impl was derived && !cx.tcx.has_attr(item.owner_id, sym::automatically_derived) @@ -215,7 +443,23 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug { && let body = cx.tcx.hir().body(*body_id) && let ExprKind::Block(block, _) = body.value.kind // inspect `self` +<<<<<<< HEAD +<<<<<<< HEAD + && let self_ty = cx.tcx.type_of(self_path_did).skip_binder().peel_refs() +======= +<<<<<<< HEAD +<<<<<<< HEAD + && let self_ty = cx.tcx.type_of(self_path.res.def_id()).skip_binder().peel_refs() +======= + && let self_ty = cx.tcx.type_of(self_path.res.def_id()).0.peel_refs() +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= + && let self_ty = cx.tcx.type_of(self_path_did).skip_binder().peel_refs() +>>>>>>> 555ceb83f ([`missing_fields_in_debug`]: make sure `self` is an adt) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= && let self_ty = cx.tcx.type_of(self_path_did).skip_binder().peel_refs() +>>>>>>> 615b25c20 (Rebase attempt number 2) && let Some(self_adt) = self_ty.ty_adt_def() && let Some(self_def_id) = self_adt.did().as_local() && let Some(Node::Item(self_item)) = cx.tcx.hir().find_by_def_id(self_def_id) @@ -223,9 +467,34 @@ impl<'tcx> LateLintPass<'tcx> for MissingFieldsInDebug { && let typeck_results = cx.tcx.typeck_body(*body_id) && should_lint(cx, typeck_results, block) { +<<<<<<< HEAD +<<<<<<< HEAD + // we intentionally only lint structs, see lint description + if let ItemKind::Struct(data, _) = &self_item.kind { + check_struct(cx, typeck_results, block, self_ty, item, data); +======= +<<<<<<< HEAD +<<<<<<< HEAD + // we intentionally only lint structs, see lint description + if let ItemKind::Struct(data, _) = &self_item.kind { + check_struct(cx, typeck_results, block, self_ty, item, data); +======= + match &self_item.kind { + ItemKind::Struct(data, _) => check_struct(cx, typeck_results, block, self_ty, item, data), + ItemKind::Enum(..) => check_enum(cx, typeck_results, block, self_ty, item), + _ => {} +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= + // we intentionally only lint structs, see lint description + if let ItemKind::Struct(data, _) = &self_item.kind { + check_struct(cx, typeck_results, block, self_ty, item, data); +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // we intentionally only lint structs, see lint description if let ItemKind::Struct(data, _) = &self_item.kind { check_struct(cx, typeck_results, block, self_ty, item, data); +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } diff --git a/clippy_lints/src/mixed_read_write_in_expression.rs b/clippy_lints/src/mixed_read_write_in_expression.rs index 57ec3a1f1e63..1acaeb1e3c58 100644 --- a/clippy_lints/src/mixed_read_write_in_expression.rs +++ b/clippy_lints/src/mixed_read_write_in_expression.rs @@ -138,6 +138,16 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { fn visit_expr(&mut self, e: &'tcx Expr<'_>) { match e.kind { // fix #10776 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 35aff1ae8 (refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ExprKind::Block(block, ..) => match (block.stmts, block.expr) { ([], Some(e)) => self.visit_expr(e), ([stmt], None) => match stmt.kind { @@ -145,6 +155,30 @@ impl<'a, 'tcx> Visitor<'tcx> for DivergenceVisitor<'a, 'tcx> { _ => {}, }, _ => {}, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + ExprKind::Block(block, ..) => { + if let Some(e) = block.expr && block.stmts.is_empty() { + self.visit_expr(e); + + return; + } + + if let [stmt, rest @ ..] = block.stmts && rest.is_empty() { + match stmt.kind { + StmtKind::Expr(e) | StmtKind::Semi(e) => self.visit_expr(e), + _ => {}, + } + } +>>>>>>> 5825b9e3e (actually fix it) +======= +>>>>>>> 35aff1ae8 (refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }, ExprKind::Continue(_) | ExprKind::Break(_, _) | ExprKind::Ret(_) => self.report_diverging_sub_expr(e), ExprKind::Call(func, _) => { diff --git a/clippy_lints/src/module_style.rs b/clippy_lints/src/module_style.rs index efdc7560ee49..efb6728448d7 100644 --- a/clippy_lints/src/module_style.rs +++ b/clippy_lints/src/module_style.rs @@ -93,6 +93,16 @@ impl EarlyLintPass for ModStyle { // `{ foo => path/to/foo.rs, .. } let mut file_map = FxHashMap::default(); for file in files.iter() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e11ebbd5e (Move continue into if statement) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let FileName::Real(name) = &file.name && let Some(lp) = name.local_path() && file.cnum == LOCAL_CRATE @@ -101,6 +111,25 @@ impl EarlyLintPass for ModStyle { // Only check files in the current crate. // Fix false positive that crate dependency in workspace sub directory // is checked unintentionally. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if let FileName::Real(name) = &file.name && let Some(lp) = name.local_path() { + if file.cnum != LOCAL_CRATE { + // [#8887](/~https://github.com/rust-lang/rust-clippy/issues/8887) + // Only check files in the current crate. + // Fix false positive that crate dependency in workspace sub directory + // is checked unintentionally. + continue; + } +>>>>>>> 65b93a5b4 (Fix false positive of [self_named_module_files] and [mod_module_files]) +======= +>>>>>>> e11ebbd5e (Move continue into if statement) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let path = if lp.is_relative() { lp } else if let Ok(relative) = lp.strip_prefix(trim_to_src) { diff --git a/clippy_lints/src/needless_bool.rs b/clippy_lints/src/needless_bool.rs index 46457400abcb..e27147a4b273 100644 --- a/clippy_lints/src/needless_bool.rs +++ b/clippy_lints/src/needless_bool.rs @@ -209,7 +209,24 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessBool { } if let Some((lhs_a, a)) = fetch_assign(then) && let Some((lhs_b, b)) = fetch_assign(r#else) && +<<<<<<< HEAD +<<<<<<< HEAD SpanlessEq::new(cx).eq_expr(lhs_a, lhs_b) +======= +<<<<<<< HEAD +<<<<<<< HEAD + SpanlessEq::new(cx).eq_expr(lhs_a, lhs_b) +======= + SpanlessEq::new(cx).eq_expr(lhs_a, lhs_b) && + span_extract_comment(cx.tcx.sess.source_map(), e.span).is_empty() +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= + SpanlessEq::new(cx).eq_expr(lhs_a, lhs_b) +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + SpanlessEq::new(cx).eq_expr(lhs_a, lhs_b) +>>>>>>> 615b25c20 (Rebase attempt number 2) { let mut applicability = Applicability::MachineApplicable; let cond = Sugg::hir_with_applicability(cx, cond, "..", &mut applicability); diff --git a/clippy_lints/src/needless_else.rs b/clippy_lints/src/needless_else.rs index 03bab86c6d7c..e6ad0d4c57f2 100644 --- a/clippy_lints/src/needless_else.rs +++ b/clippy_lints/src/needless_else.rs @@ -1,5 +1,29 @@ +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::{snippet_opt, trim_span}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::source::snippet_opt; +use clippy_utils::{diagnostics::span_lint_and_sugg, source::trim_span}; +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, source::trim_span, span_extract_comment}; +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +use clippy_utils::source::snippet_opt; +use clippy_utils::{diagnostics::span_lint_and_sugg, source::trim_span}; +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +======= +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::source::{snippet_opt, trim_span}; +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::diagnostics::span_lint_and_sugg; +use clippy_utils::source::{snippet_opt, trim_span}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_ast::ast::{Expr, ExprKind}; use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; @@ -36,6 +60,16 @@ declare_lint_pass!(NeedlessElse => [NEEDLESS_ELSE]); impl EarlyLintPass for NeedlessElse { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let ExprKind::If(_, then_block, Some(else_clause)) = &expr.kind && let ExprKind::Block(block, _) = &else_clause.kind && !expr.span.from_expansion() @@ -57,5 +91,34 @@ impl EarlyLintPass for NeedlessElse { Applicability::MachineApplicable, ); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + if let ExprKind::If(_, then_block, Some(else_clause)) = &expr.kind && + let ExprKind::Block(block, _) = &else_clause.kind && + !expr.span.from_expansion() && + !else_clause.span.from_expansion() && + block.stmts.is_empty() { + let span = trim_span(cx.sess().source_map(), expr.span.trim_start(then_block.span).unwrap()); + if span_extract_comment(cx.sess().source_map(), span).is_empty() { + span_lint_and_sugg( + cx, + NEEDLESS_ELSE, + span, + "this else branch is empty", + "you can remove it", + String::new(), + Applicability::MachineApplicable, + ); + } + } +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } diff --git a/clippy_lints/src/needless_if.rs b/clippy_lints/src/needless_if.rs index 1ed7ea6b3255..8d8f61b04922 100644 --- a/clippy_lints/src/needless_if.rs +++ b/clippy_lints/src/needless_if.rs @@ -1,15 +1,63 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{diagnostics::span_lint_and_sugg, higher::If, is_from_proc_macro, source::snippet_opt}; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::higher::If; use clippy_utils::is_from_proc_macro; use clippy_utils::source::snippet_opt; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_errors::Applicability; use rustc_hir::{ExprKind, Stmt, StmtKind}; +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +use rustc_errors::Applicability; +use rustc_hir::{ExprKind, Stmt, StmtKind}; +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, is_from_proc_macro, source::snippet_with_applicability}; +use rustc_errors::Applicability; +<<<<<<< HEAD +use rustc_hir::{Expr, ExprKind, Node}; +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +use rustc_hir::{ + intravisit::{walk_expr, Visitor}, + Expr, ExprKind, Node, +}; +>>>>>>> 59bca098f (don't lint on `if let`) +======= +use clippy_utils::{diagnostics::span_lint_and_sugg, higher::If, is_from_proc_macro, source::snippet_opt}; +use rustc_errors::Applicability; +use rustc_hir::{ExprKind, Stmt, StmtKind}; +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_errors::Applicability; +use rustc_hir::{ExprKind, Stmt, StmtKind}; +>>>>>>> 615b25c20 (Rebase attempt number 2) 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 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Checks for empty `if` branches with no else branch. /// /// ### Why is this bad? @@ -28,6 +76,42 @@ declare_clippy_lint! { /// ```rust,ignore /// // /// really_expensive_condition_with_side_effects(&mut i); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= + /// Checks for empty `if` statements with no else branch. +>>>>>>> b2bdc37a5 (add description) +======= + /// Checks for empty `if` branches with no else branch. +>>>>>>> 59bca098f (don't lint on `if let`) + /// + /// ### Why is this bad? + /// It can be entirely omitted, and often the condition too. + /// + /// ### Known issues + /// This will usually only suggest to remove the `if` statement, not the condition. Other lints + /// such as `no_effect` will take care of removing the condition if it's unnecessary. + /// + /// ### Example + /// ```rust,ignore + /// if really_expensive_condition(&i) {} + /// if really_expensive_condition_with_side_effects(&mut i) {} + /// ``` + /// Use instead: +<<<<<<< HEAD + /// ```rust + /// // example code which does not raise clippy warning +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + /// ```rust,ignore + /// // + /// really_expensive_condition_with_side_effects(&mut i); +>>>>>>> b2bdc37a5 (add description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` #[clippy::version = "1.72.0"] pub NEEDLESS_IF, @@ -37,10 +121,27 @@ declare_clippy_lint! { declare_lint_pass!(NeedlessIf => [NEEDLESS_IF]); impl LateLintPass<'_> for NeedlessIf { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn check_stmt<'tcx>(&mut self, cx: &LateContext<'tcx>, stmt: &Stmt<'tcx>) { if let StmtKind::Expr(expr) = stmt.kind && let Some(If {cond, then, r#else: None }) = If::hir(expr) && let ExprKind::Block(block, ..) = then.kind +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && block.stmts.is_empty() && block.expr.is_none() && !in_external_macro(cx.sess(), expr.span) @@ -71,7 +172,66 @@ impl LateLintPass<'_> for NeedlessIf { } else { String::new() }, +<<<<<<< HEAD +<<<<<<< HEAD + Applicability::MachineApplicable, +======= +======= + fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'tcx>) { + if let ExprKind::If(if_expr, block, else_expr) = &expr.kind + && let ExprKind::Block(block, ..) = block.kind +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) + && block.stmts.is_empty() + && block.expr.is_none() + && !in_external_macro(cx.sess(), expr.span) + && !is_from_proc_macro(cx, expr) + && let Some(then_snippet) = snippet_opt(cx, then.span) + // Ignore + // - empty macro expansions + // - empty reptitions in macro expansions + // - comments + // - #[cfg]'d out code + && then_snippet.chars().all(|ch| matches!(ch, '{' | '}') || ch.is_ascii_whitespace()) + && let Some(cond_snippet) = snippet_opt(cx, cond.span) + { + span_lint_and_sugg( + cx, + NEEDLESS_IF, + stmt.span, + "this `if` branch is empty", + "you can remove it", +<<<<<<< HEAD +<<<<<<< HEAD + format!("{snippet};"), +>>>>>>> 26f50395b (Add `needless_if` lint) + Applicability::MachineApplicable, +======= + if if_expr.can_have_side_effects() { + format!("{snippet};") + } else { + String::new() + }, + app, +>>>>>>> 59bca098f (don't lint on `if let`) +======= + if cond.can_have_side_effects() || !cx.tcx.hir().attrs(stmt.hir_id).is_empty() { + // `{ foo }` or `{ foo } && bar` placed into a statement position would be + // interpreted as a block statement, force it to be an expression + if cond_snippet.starts_with('{') { + format!("({cond_snippet});") + } else { + format!("{cond_snippet};") + } + } else { + String::new() + }, + Applicability::MachineApplicable, +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= Applicability::MachineApplicable, +>>>>>>> 615b25c20 (Rebase attempt number 2) ); } } diff --git a/clippy_lints/src/needless_pass_by_value.rs b/clippy_lints/src/needless_pass_by_value.rs index aee156c76914..cb8d5762abed 100644 --- a/clippy_lints/src/needless_pass_by_value.rs +++ b/clippy_lints/src/needless_pass_by_value.rs @@ -17,7 +17,15 @@ use rustc_hir_typeck::expr_use_visitor as euv; use rustc_infer::infer::TyCtxtInferExt; use rustc_lint::{LateContext, LateLintPass}; use rustc_middle::mir::FakeReadCause; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_middle::ty::{self, Ty, TypeVisitableExt}; +======= +use rustc_middle::ty::{self, TypeVisitableExt, Ty}; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_middle::ty::{self, Ty, TypeVisitableExt}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::def_id::LocalDefId; use rustc_span::symbol::kw; @@ -168,7 +176,15 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByValue { ( preds.iter().any(|t| cx.tcx.is_diagnostic_item(sym::Borrow, t.def_id())), !preds.is_empty() && { +<<<<<<< HEAD +<<<<<<< HEAD + let ty_empty_region = Ty::new_imm_ref(cx.tcx, cx.tcx.lifetimes.re_erased, ty); +======= + let ty_empty_region = Ty::new_imm_ref(cx.tcx,cx.tcx.lifetimes.re_erased, ty); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let ty_empty_region = Ty::new_imm_ref(cx.tcx, cx.tcx.lifetimes.re_erased, ty); +>>>>>>> 615b25c20 (Rebase attempt number 2) preds.iter().all(|t| { let ty_params = t.trait_ref.substs.iter().skip(1).collect::>(); implements_trait(cx, ty_empty_region, t.def_id(), &ty_params) diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index e31fd20dfca5..ba19ed284c57 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -15,12 +15,28 @@ use rustc_hir::{ }; use rustc_hir_analysis::hir_ty_to_ty; use rustc_lint::{LateContext, LateLintPass, Lint}; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId}; +======= +use rustc_middle::mir::interpret::ErrorHandled; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_middle::mir::interpret::{ErrorHandled, EvalToValTreeResult, GlobalId}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_middle::ty::adjustment::Adjust; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_span::{sym, InnerSpan, Span}; use rustc_target::abi::VariantIdx; +<<<<<<< HEAD +<<<<<<< HEAD +======= +use rustc_middle::mir::interpret::EvalToValTreeResult; +use rustc_middle::mir::interpret::GlobalId; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // FIXME: this is a correctness problem but there's no suitable // warn-by-default category. @@ -152,7 +168,46 @@ fn is_value_unfrozen_raw<'tcx>( // As of 2022-09-08 miri doesn't track which union field is active so there's no safe way to check the // contained value. ty::Adt(def, ..) if def.is_union() => false, +<<<<<<< HEAD +<<<<<<< HEAD + ty::Array(ty, _) => val.unwrap_branch().iter().any(|field| inner(cx, *field, ty)), + ty::Adt(def, _) if def.is_union() => false, + ty::Adt(def, substs) if def.is_enum() => { + let (&variant_index, fields) = val.unwrap_branch().split_first().unwrap(); + let variant_index = VariantIdx::from_u32(variant_index.unwrap_leaf().try_to_u32().ok().unwrap()); + fields + .iter() + .copied() + .zip( + def.variants()[variant_index] + .fields + .iter() + .map(|field| field.ty(cx.tcx, substs)), + ) + .any(|(field, ty)| inner(cx, field, ty)) + }, + ty::Adt(def, substs) => val + .unwrap_branch() + .iter() + .zip( + def.non_enum_variant() + .fields + .iter() + .map(|field| field.ty(cx.tcx, substs)), + ) + .any(|(field, ty)| inner(cx, *field, ty)), + ty::Tuple(tys) => val + .unwrap_branch() + .iter() + .zip(tys) + .any(|(field, ty)| inner(cx, *field, ty)), +======= + ty::Array(ty, _) => { + val.unwrap_branch().iter().any(|field| inner(cx, *field, ty)) + }, +======= ty::Array(ty, _) => val.unwrap_branch().iter().any(|field| inner(cx, *field, ty)), +>>>>>>> 615b25c20 (Rebase attempt number 2) ty::Adt(def, _) if def.is_union() => false, ty::Adt(def, substs) if def.is_enum() => { let (&variant_index, fields) = val.unwrap_branch().split_first().unwrap(); @@ -175,6 +230,15 @@ fn is_value_unfrozen_raw<'tcx>( def.non_enum_variant() .fields .iter() +<<<<<<< HEAD + .map(|field| field.ty(cx.tcx, substs))).any(|(field, ty)| inner(cx, field, ty)) + } + ty::Adt(def, substs) => { + val.unwrap_branch().iter().zip(def.non_enum_variant().fields.iter().map(|field| field.ty(cx.tcx, substs))).any(|(field, ty)| inner(cx, *field, ty)) + } + ty::Tuple(tys) => val.unwrap_branch().iter().zip(tys).any(|(field, ty)| inner(cx, *field, ty)), +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= .map(|field| field.ty(cx.tcx, substs)), ) .any(|(field, ty)| inner(cx, *field, ty)), @@ -183,6 +247,7 @@ fn is_value_unfrozen_raw<'tcx>( .iter() .zip(tys) .any(|(field, ty)| inner(cx, *field, ty)), +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => false, } } @@ -219,10 +284,20 @@ fn is_value_unfrozen_poly<'tcx>(cx: &LateContext<'tcx>, body_id: BodyId, ty: Ty< let def_id = body_id.hir_id.owner.to_def_id(); let substs = ty::InternalSubsts::identity_for_item(cx.tcx, def_id); let instance = ty::Instance::new(def_id, substs); +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let cid = rustc_middle::mir::interpret::GlobalId { instance, promoted: None, }; +<<<<<<< HEAD +======= + let cid = rustc_middle::mir::interpret::GlobalId { instance, promoted: None }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let param_env = cx.tcx.param_env(def_id).with_reveal_all_normalized(cx.tcx); let result = cx.tcx.const_eval_global_id_for_typeck(param_env, cid, None); is_value_unfrozen_raw(cx, result, ty) @@ -235,6 +310,13 @@ fn is_value_unfrozen_expr<'tcx>(cx: &LateContext<'tcx>, hir_id: HirId, def_id: D is_value_unfrozen_raw(cx, result, ty) } +<<<<<<< HEAD +<<<<<<< HEAD +======= + +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) pub fn const_eval_resolve<'tcx>( tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>, @@ -243,12 +325,26 @@ pub fn const_eval_resolve<'tcx>( ) -> EvalToValTreeResult<'tcx> { match ty::Instance::resolve(tcx, param_env, ct.def, ct.substs) { Ok(Some(instance)) => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let cid = GlobalId { instance, promoted: None, }; +<<<<<<< HEAD + tcx.const_eval_global_id_for_typeck(param_env, cid, span) + }, +======= + let cid = GlobalId { instance, promoted: None }; + tcx.const_eval_global_id_for_typeck(param_env, cid, span) + } +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= tcx.const_eval_global_id_for_typeck(param_env, cid, span) }, +>>>>>>> 615b25c20 (Rebase attempt number 2) Ok(None) => Err(ErrorHandled::TooGeneric), Err(err) => Err(ErrorHandled::Reported(err.into())), } diff --git a/clippy_lints/src/operators/arithmetic_side_effects.rs b/clippy_lints/src/operators/arithmetic_side_effects.rs index 35dd8fabe6e6..fc429030b1da 100644 --- a/clippy_lints/src/operators/arithmetic_side_effects.rs +++ b/clippy_lints/src/operators/arithmetic_side_effects.rs @@ -194,9 +194,26 @@ impl ArithmeticSideEffects { ps: &hir::PathSegment<'tcx>, receiver: &hir::Expr<'tcx>, ) { +<<<<<<< HEAD +<<<<<<< HEAD let Some(arg) = args.first() else { return; }; +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + const METHODS: &[&str] = &["saturating_div", "wrapping_div", "wrapping_rem", "wrapping_rem_euclid"]; +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +======= +>>>>>>> 0b16f80c4 ([arithmetic_side_effects] Cache symbols) + let Some(arg) = args.first() else { return; }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let Some(arg) = args.first() else { + return; + }; +>>>>>>> 615b25c20 (Rebase attempt number 2) if constant_simple(cx, cx.typeck_results(), receiver).is_some() { return; } @@ -204,7 +221,23 @@ impl ArithmeticSideEffects { if !Self::is_integral(instance_ty) { return; } +<<<<<<< HEAD +<<<<<<< HEAD + if !self.integer_methods.contains(&ps.ident.name) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + if !self.integer_methods.contains(&ps.ident.name) { +======= + if METHODS.iter().copied().all(|method| method != ps.ident.as_str()) { +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +======= + if !self.integer_methods.contains(&ps.ident.name) { +>>>>>>> 0b16f80c4 ([arithmetic_side_effects] Cache symbols) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if !self.integer_methods.contains(&ps.ident.name) { +>>>>>>> 615b25c20 (Rebase attempt number 2) return; } let (actual_arg, _) = peel_hir_expr_refs(arg); diff --git a/clippy_lints/src/operators/float_cmp.rs b/clippy_lints/src/operators/float_cmp.rs index f3e0c58a7871..0f23d253b1ef 100644 --- a/clippy_lints/src/operators/float_cmp.rs +++ b/clippy_lints/src/operators/float_cmp.rs @@ -85,7 +85,23 @@ fn get_lint_and_message(is_local: bool, is_comparing_arrays: bool) -> (&'static } } +<<<<<<< HEAD +<<<<<<< HEAD fn is_allowed(val: &Constant<'_>) -> bool { +======= +<<<<<<< HEAD +<<<<<<< HEAD +fn is_allowed(val: &Constant<'_>) -> bool { +======= +fn is_allowed(val: &Constant) -> bool { +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= +fn is_allowed(val: &Constant<'_>) -> bool { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +fn is_allowed(val: &Constant<'_>) -> bool { +>>>>>>> 615b25c20 (Rebase attempt number 2) match val { &Constant::F32(f) => f == 0.0 || f.is_infinite(), &Constant::F64(f) => f == 0.0 || f.is_infinite(), diff --git a/clippy_lints/src/operators/numeric_arithmetic.rs b/clippy_lints/src/operators/numeric_arithmetic.rs index 102845ceed09..ce76f6450fe6 100644 --- a/clippy_lints/src/operators/numeric_arithmetic.rs +++ b/clippy_lints/src/operators/numeric_arithmetic.rs @@ -43,8 +43,59 @@ impl Context { _ => (), } +<<<<<<< HEAD +<<<<<<< HEAD let (_, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() { +======= +<<<<<<< HEAD +<<<<<<< HEAD + let (l_ty, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); + if l_ty.peel_refs().is_integral() && r_ty.peel_refs().is_integral() { +<<<<<<< HEAD +<<<<<<< HEAD + if is_from_proc_macro(cx, expr) { +======= + if Self::skip_expr_involving_integers(cx, expr) { +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + if is_from_proc_macro(cx, expr) { +>>>>>>> d6390625d (Address comments) + return; + } + match op { + hir::BinOpKind::Div | hir::BinOpKind::Rem => match &r.kind { + hir::ExprKind::Lit(_lit) => (), + hir::ExprKind::Unary(hir::UnOp::Neg, expr) => { + if is_integer_literal(expr, 1) { + span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); + self.expr_id = Some(expr.hir_id); + } + }, + _ => { + span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); + self.expr_id = Some(expr.hir_id); + }, + }, + _ => { + span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); + self.expr_id = Some(expr.hir_id); + }, + } + } else if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() { +======= + let (_, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); + if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() { +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= + let (_, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); + if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() { +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let (_, r_ty) = (cx.typeck_results().expr_ty(l), cx.typeck_results().expr_ty(r)); + if r_ty.peel_refs().is_floating_point() && r_ty.peel_refs().is_floating_point() { +>>>>>>> 615b25c20 (Rebase attempt number 2) span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); self.expr_id = Some(expr.hir_id); } @@ -55,9 +106,49 @@ impl Context { return; } let ty = cx.typeck_results().expr_ty(arg); +<<<<<<< HEAD +<<<<<<< HEAD + if constant_simple(cx, cx.typeck_results(), expr).is_none() && ty.is_floating_point() { + span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); + self.expr_id = Some(expr.hir_id); +======= +<<<<<<< HEAD +<<<<<<< HEAD + if constant_simple(cx, cx.typeck_results(), expr).is_none() { + if ty.is_integral() { +<<<<<<< HEAD +<<<<<<< HEAD + if is_from_proc_macro(cx, expr) { +======= + if Self::skip_expr_involving_integers(cx, expr) { +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + if is_from_proc_macro(cx, expr) { +>>>>>>> d6390625d (Address comments) + return; + } + span_lint(cx, INTEGER_ARITHMETIC, expr.span, "integer arithmetic detected"); + self.expr_id = Some(expr.hir_id); + } else if ty.is_floating_point() { + span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); + self.expr_id = Some(expr.hir_id); + } +======= + if constant_simple(cx, cx.typeck_results(), expr).is_none() && ty.is_floating_point() { + span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); + self.expr_id = Some(expr.hir_id); +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= + if constant_simple(cx, cx.typeck_results(), expr).is_none() && ty.is_floating_point() { + span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); + self.expr_id = Some(expr.hir_id); +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if constant_simple(cx, cx.typeck_results(), expr).is_none() && ty.is_floating_point() { span_lint(cx, FLOAT_ARITHMETIC, expr.span, "floating-point arithmetic detected"); self.expr_id = Some(expr.hir_id); +>>>>>>> 615b25c20 (Rebase attempt number 2) } } diff --git a/clippy_lints/src/ptr.rs b/clippy_lints/src/ptr.rs index 82a55166aeae..bbfac7368cce 100644 --- a/clippy_lints/src/ptr.rs +++ b/clippy_lints/src/ptr.rs @@ -388,12 +388,29 @@ impl<'tcx> DerefTy<'tcx> { fn ty(&self, cx: &LateContext<'tcx>) -> Ty<'tcx> { match *self { Self::Str => cx.tcx.types.str_, +<<<<<<< HEAD +<<<<<<< HEAD Self::Path => Ty::new_adt( cx.tcx, cx.tcx.adt_def(cx.tcx.get_diagnostic_item(sym::Path).unwrap()), List::empty(), ), Self::Slice(_, ty) => Ty::new_slice(cx.tcx, ty), +======= + Self::Path => Ty::new_adt(cx.tcx, + cx.tcx.adt_def(cx.tcx.get_diagnostic_item(sym::Path).unwrap()), + List::empty(), + ), + Self::Slice(_, ty) => Ty::new_slice(cx.tcx,ty), +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + Self::Path => Ty::new_adt( + cx.tcx, + cx.tcx.adt_def(cx.tcx.get_diagnostic_item(sym::Path).unwrap()), + List::empty(), + ), + Self::Slice(_, ty) => Ty::new_slice(cx.tcx, ty), +>>>>>>> 615b25c20 (Rebase attempt number 2) } } diff --git a/clippy_lints/src/question_mark.rs b/clippy_lints/src/question_mark.rs index f5502cffb669..3dabff8c4f29 100644 --- a/clippy_lints/src/question_mark.rs +++ b/clippy_lints/src/question_mark.rs @@ -53,7 +53,23 @@ pub struct QuestionMark { /// very quickly, without having to walk up the parent chain, by simply checking /// if it is greater than zero. /// As for why we need this in the first place: +<<<<<<< HEAD +<<<<<<< HEAD try_block_depth_stack: Vec, +======= +<<<<<<< HEAD +<<<<<<< HEAD + try_block_depth_stack: Vec, +======= + try_block_depth: u32, +>>>>>>> 716305d4b ([`question_mark`]: don't lint inside of `try` block) +======= + try_block_depth_stack: Vec, +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + try_block_depth_stack: Vec, +>>>>>>> 615b25c20 (Rebase attempt number 2) } impl_lint_pass!(QuestionMark => [QUESTION_MARK, MANUAL_LET_ELSE]); @@ -189,7 +205,23 @@ fn expr_return_none_or_err( impl QuestionMark { fn inside_try_block(&self) -> bool { +<<<<<<< HEAD +<<<<<<< HEAD + self.try_block_depth_stack.last() > Some(&0) +======= +<<<<<<< HEAD +<<<<<<< HEAD + self.try_block_depth_stack.last() > Some(&0) +======= + self.try_block_depth > 0 +>>>>>>> 716305d4b ([`question_mark`]: don't lint inside of `try` block) +======= + self.try_block_depth_stack.last() > Some(&0) +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= self.try_block_depth_stack.last() > Some(&0) +>>>>>>> 615b25c20 (Rebase attempt number 2) } /// Checks if the given expression on the given context matches the following structure: @@ -313,10 +345,51 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark { fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx rustc_hir::Block<'tcx>) { if is_try_block(cx, block) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) *self .try_block_depth_stack .last_mut() .expect("blocks are always part of bodies and must have a depth") += 1; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + } + } + + fn check_body(&mut self, _: &LateContext<'tcx>, _: &'tcx rustc_hir::Body<'tcx>) { + self.try_block_depth_stack.push(0); + } + + fn check_body_post(&mut self, _: &LateContext<'tcx>, _: &'tcx rustc_hir::Body<'tcx>) { + self.try_block_depth_stack.pop(); + } + + fn check_block_post(&mut self, cx: &LateContext<'tcx>, block: &'tcx rustc_hir::Block<'tcx>) { + if is_try_block(cx, block) { + *self + .try_block_depth_stack + .last_mut() + .expect("blocks are always part of bodies and must have a depth") -= 1; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + self.try_block_depth += 1; +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) } } @@ -330,10 +403,18 @@ impl<'tcx> LateLintPass<'tcx> for QuestionMark { fn check_block_post(&mut self, cx: &LateContext<'tcx>, block: &'tcx rustc_hir::Block<'tcx>) { if is_try_block(cx, block) { +<<<<<<< HEAD + self.try_block_depth -= 1; +>>>>>>> 716305d4b ([`question_mark`]: don't lint inside of `try` block) +======= *self .try_block_depth_stack .last_mut() .expect("blocks are always part of bodies and must have a depth") -= 1; +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } extract_msrv_attr!(LateContext); diff --git a/clippy_lints/src/raw_strings.rs b/clippy_lints/src/raw_strings.rs index ccabb577cb72..cc1b7615e164 100644 --- a/clippy_lints/src/raw_strings.rs +++ b/clippy_lints/src/raw_strings.rs @@ -1,3 +1,26 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +use std::{iter::once, ops::ControlFlow}; + +======= +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +use std::{iter::once, ops::ControlFlow}; + +>>>>>>> 8cb6c8699 (change category and refactor) +use clippy_utils::{diagnostics::span_lint_and_sugg, source::snippet}; +use rustc_ast::{ + ast::{Expr, ExprKind}, + token::LitKind, +}; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::iter::once; use std::ops::ControlFlow; @@ -5,6 +28,13 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::source::snippet; use rustc_ast::ast::{Expr, ExprKind}; use rustc_ast::token::LitKind; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_errors::Applicability; use rustc_lint::{EarlyContext, EarlyLintPass, LintContext}; use rustc_middle::lint::in_external_macro; @@ -15,8 +45,27 @@ declare_clippy_lint! { /// Checks for raw string literals where a string literal can be used instead. /// /// ### Why is this bad? +<<<<<<< HEAD +<<<<<<< HEAD /// It's just unnecessary, but there are many cases where using a raw string literal is more /// idiomatic than a string literal, so it's opt-in. +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// It's just unnecessary, but there are many cases where using a raw string literal is more + /// idiomatic than a string literal, so it's opt-in. +======= + /// It's just unnecessary. +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + /// It's just unnecessary, but there are many cases where using a raw string literal is more + /// idiomatic than a string literal, so it's opt-in. +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// It's just unnecessary, but there are many cases where using a raw string literal is more + /// idiomatic than a string literal, so it's opt-in. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Example /// ```rust @@ -27,8 +76,28 @@ declare_clippy_lint! { /// let r = "Hello, world!"; /// ``` #[clippy::version = "1.72.0"] +<<<<<<< HEAD +<<<<<<< HEAD pub NEEDLESS_RAW_STRINGS, restriction, +======= +<<<<<<< HEAD +<<<<<<< HEAD + pub NEEDLESS_RAW_STRINGS, + restriction, +======= + pub NEEDLESS_RAW_STRING, + complexity, +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + pub NEEDLESS_RAW_STRINGS, + restriction, +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + pub NEEDLESS_RAW_STRINGS, + restriction, +>>>>>>> 615b25c20 (Rebase attempt number 2) "suggests using a string literal when a raw string literal is unnecessary" } declare_clippy_lint! { @@ -49,10 +118,36 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.72.0"] pub NEEDLESS_RAW_STRING_HASHES, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) style, "suggests reducing the number of hashes around a raw string literal" } impl_lint_pass!(RawStrings => [NEEDLESS_RAW_STRINGS, NEEDLESS_RAW_STRING_HASHES]); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + complexity, + "suggests reducing the number of hashes around a raw string literal" +} +impl_lint_pass!(RawStrings => [NEEDLESS_RAW_STRING, NEEDLESS_RAW_STRING_HASHES]); +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + style, + "suggests reducing the number of hashes around a raw string literal" +} +impl_lint_pass!(RawStrings => [NEEDLESS_RAW_STRINGS, NEEDLESS_RAW_STRING_HASHES]); +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) pub struct RawStrings { pub needless_raw_string_hashes_allow_one: bool, @@ -62,9 +157,32 @@ impl EarlyLintPass for RawStrings { fn check_expr(&mut self, cx: &EarlyContext<'_>, expr: &Expr) { if !in_external_macro(cx.sess(), expr.span) && let ExprKind::Lit(lit) = expr.kind +<<<<<<< HEAD +<<<<<<< HEAD + && let LitKind::StrRaw(max) | LitKind::ByteStrRaw(max) | LitKind::CStrRaw(max) = lit.kind + { + let str = lit.symbol.as_str(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + && let LitKind::StrRaw(max) | LitKind::ByteStrRaw(max) | LitKind::CStrRaw(max) = lit.kind + { + let str = lit.symbol.as_str(); +======= + && let LitKind::StrRaw(num) | LitKind::ByteStrRaw(num) | LitKind::CStrRaw(num) = lit.kind + { +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + && let LitKind::StrRaw(max) | LitKind::ByteStrRaw(max) | LitKind::CStrRaw(max) = lit.kind + { + let str = lit.symbol.as_str(); +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= && let LitKind::StrRaw(max) | LitKind::ByteStrRaw(max) | LitKind::CStrRaw(max) = lit.kind { let str = lit.symbol.as_str(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let prefix = match lit.kind { LitKind::StrRaw(..) => "r", LitKind::ByteStrRaw(..) => "br", @@ -75,10 +193,38 @@ impl EarlyLintPass for RawStrings { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + if !str.contains(['\\', '"']) { + span_lint_and_sugg( + cx, + NEEDLESS_RAW_STRINGS, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + if !lit.symbol.as_str().contains(['\\', '"']) { + span_lint_and_sugg( + cx, + NEEDLESS_RAW_STRING, +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +======= if !str.contains(['\\', '"']) { span_lint_and_sugg( cx, NEEDLESS_RAW_STRINGS, +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) expr.span, "unnecessary raw string literal", "try", @@ -89,6 +235,16 @@ impl EarlyLintPass for RawStrings { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let req = { let mut following_quote = false; let mut req = 0; @@ -107,6 +263,13 @@ impl EarlyLintPass for RawStrings { _ => { if following_quote { following_quote = false; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if req == max { return ControlFlow::Break(req); @@ -126,6 +289,49 @@ impl EarlyLintPass for RawStrings { }; if req < max { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + #[allow(clippy::cast_possible_truncation)] +======= +======= +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) + #[expect(clippy::cast_possible_truncation)] +>>>>>>> ec765d951 (Update raw_strings.rs) + let req = lit.symbol.as_str().as_bytes() + .split(|&b| b == b'"') + .skip(1) + .map(|bs| 1 + bs.iter().take_while(|&&b| b == b'#').count() as u8) + .max() + .unwrap_or(0); + + if req < num { +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + + if req == max { + return ControlFlow::Break(req); + } + + return ControlFlow::Continue(acc.max(req)); + } + }, + } + + ControlFlow::Continue(acc) + }); + + match num { + ControlFlow::Continue(num) | ControlFlow::Break(num) => num, + } + }; + + if req < max { +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let hashes = "#".repeat(req as usize); span_lint_and_sugg( @@ -138,6 +344,30 @@ impl EarlyLintPass for RawStrings { Applicability::MachineApplicable, ); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + + if !lit.symbol.as_str().contains(['\\', '"']) { + span_lint_and_sugg( + cx, + NEEDLESS_RAW_STRING, + expr.span, + "unnecessary raw string literal", + "try", + format!("{}\"{}\"", prefix.replace('r', ""), lit.symbol), + Applicability::MachineApplicable, + ); + } +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } diff --git a/clippy_lints/src/redundant_closure_call.rs b/clippy_lints/src/redundant_closure_call.rs index 4e3efe97b8c6..51c591c5155d 100644 --- a/clippy_lints/src/redundant_closure_call.rs +++ b/clippy_lints/src/redundant_closure_call.rs @@ -57,6 +57,20 @@ impl<'tcx> Visitor<'tcx> for ReturnVisitor { } else { hir_visit::walk_expr(self, ex); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + + hir_visit::walk_expr(self, ex); +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } @@ -73,7 +87,23 @@ fn is_async_closure(body: &hir::Body<'_>) -> bool { } /// Tries to find the innermost closure: +<<<<<<< HEAD +<<<<<<< HEAD +/// ```rust,ignore +======= +<<<<<<< HEAD +<<<<<<< HEAD +/// ```rust,ignore +======= +/// ```rust +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= /// ```rust,ignore +>>>>>>> e305b0730 (fix docs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +/// ```rust,ignore +>>>>>>> 615b25c20 (Rebase attempt number 2) /// (|| || || || 42)()()()() /// ^^^^^^^^^^^^^^ given this nested closure expression /// ^^^^^ we want to return this closure @@ -109,10 +139,36 @@ fn find_innermost_closure<'tcx>( } /// "Walks up" the chain of calls to find the outermost call expression, and returns the depth: +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +/// ```rust,ignore +/// (|| || || 3)()()() +/// ^^ this is the call expression we were given +/// ^^ this is what we want to return (and the depth is 3) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +/// ```rust +/// (|| || || 3)()()() +/// ^^ this is the call expression we were given +/// ^^ this is what we want to return (and the depth is 3) +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= /// ```rust,ignore /// (|| || || 3)()()() /// ^^ this is the call expression we were given /// ^^ this is what we want to return (and the depth is 3) +>>>>>>> e305b0730 (fix docs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ``` fn get_parent_call_exprs<'tcx>( cx: &LateContext<'tcx>, @@ -121,7 +177,23 @@ fn get_parent_call_exprs<'tcx>( let mut depth = 1; while let Some(parent) = get_parent_expr(cx, expr) && let hir::ExprKind::Call(recv, _) = parent.kind +<<<<<<< HEAD +<<<<<<< HEAD + && expr.span == recv.span +======= +<<<<<<< HEAD +<<<<<<< HEAD + && expr.span == recv.span +======= + && let hir::ExprKind::Call(..) = recv.kind +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= + && expr.span == recv.span +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= && expr.span == recv.span +>>>>>>> 615b25c20 (Rebase attempt number 2) { expr = parent; depth += 1; diff --git a/clippy_lints/src/redundant_type_annotations.rs b/clippy_lints/src/redundant_type_annotations.rs index 8e9234bba3c8..127e94c3d92f 100644 --- a/clippy_lints/src/redundant_type_annotations.rs +++ b/clippy_lints/src/redundant_type_annotations.rs @@ -13,6 +13,16 @@ declare_clippy_lint! { /// Code without type annotations is shorter and in most cases /// more idiomatic and easier to modify. /// +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a9b468f2b (Add `Limitations` section) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ### Limitations /// This lint doesn't support: /// @@ -21,6 +31,17 @@ declare_clippy_lint! { /// - Complex types (tuples, arrays, etc...) /// - `Path` to anything else than a primitive type. /// +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> a9b468f2b (Add `Limitations` section) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ### Example /// ```rust /// let foo: String = String::new(); @@ -31,7 +52,23 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.70.0"] pub REDUNDANT_TYPE_ANNOTATIONS, +<<<<<<< HEAD +<<<<<<< HEAD restriction, +======= +<<<<<<< HEAD +<<<<<<< HEAD + restriction, +======= + pedantic, +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + restriction, +>>>>>>> 6776608f2 (Move `redundant_type_annotations` to restriction) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + restriction, +>>>>>>> 615b25c20 (Rebase attempt number 2) "warns about needless / redundant type annotations." } declare_lint_pass!(RedundantTypeAnnotations => [REDUNDANT_TYPE_ANNOTATIONS]); @@ -67,8 +104,30 @@ fn func_hir_id_to_func_ty<'tcx>(cx: &LateContext<'tcx>, hir_id: hir::hir_id::Hir } fn func_ty_to_return_type<'tcx>(cx: &LateContext<'tcx>, func_ty: Ty<'tcx>) -> Option> { +<<<<<<< HEAD +<<<<<<< HEAD if func_ty.is_fn() { Some(func_ty.fn_sig(cx.tcx).output().skip_binder()) +======= +<<<<<<< HEAD +<<<<<<< HEAD + if func_ty.is_fn() { + Some(func_ty.fn_sig(cx.tcx).output().skip_binder()) +======= + if func_ty.is_fn() + && let Some(return_type) = func_ty.fn_sig(cx.tcx).output().no_bound_vars() + { + Some(return_type) +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + if func_ty.is_fn() { + Some(func_ty.fn_sig(cx.tcx).output().skip_binder()) +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if func_ty.is_fn() { + Some(func_ty.fn_sig(cx.tcx).output().skip_binder()) +>>>>>>> 615b25c20 (Rebase attempt number 2) } else { None } @@ -117,7 +176,24 @@ fn is_redundant_in_func_call<'tcx>( false } +<<<<<<< HEAD +<<<<<<< HEAD +fn extract_primty(ty_kind: &hir::TyKind<'_>) -> Option { +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD fn extract_primty(ty_kind: &hir::TyKind<'_>) -> Option { +======= +fn extract_primty<'tcx>(ty_kind: &hir::TyKind<'tcx>) -> Option { +>>>>>>> 6f26df1c9 (Extract common logic to function) +======= +fn extract_primty(ty_kind: &hir::TyKind<'_>) -> Option { +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +fn extract_primty(ty_kind: &hir::TyKind<'_>) -> Option { +>>>>>>> 615b25c20 (Rebase attempt number 2) if let hir::TyKind::Path(ty_path) = ty_kind && let hir::QPath::Resolved(_, resolved_path_ty) = ty_path && let hir::def::Res::PrimTy(primty) = resolved_path_ty.res @@ -128,6 +204,17 @@ fn extract_primty(ty_kind: &hir::TyKind<'_>) -> Option { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 6f26df1c9 (Extract common logic to function) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) impl LateLintPass<'_> for RedundantTypeAnnotations { fn check_local<'tcx>(&mut self, cx: &LateContext<'tcx>, local: &'tcx rustc_hir::Local<'tcx>) { // type annotation part @@ -148,6 +235,14 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { } }, hir::ExprKind::MethodCall(_, _, _, _) => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut is_ref = false; let mut ty_kind = &ty.kind; @@ -166,6 +261,40 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { } else { return_type }) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + if let hir::TyKind::Path(ty_path) = &ty.kind + && let hir::QPath::Resolved(_, resolved_path_ty) = ty_path +======= + let mut is_ref = false; + let mut ty_kind = &ty.kind; +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) + + // If the annotation is a ref we "peel" it + if let hir::TyKind::Ref(_, mut_ty) = &ty.kind { + is_ref = true; + ty_kind = &mut_ty.ty.kind; + } + + if let hir::TyKind::Path(ty_path) = ty_kind + && let hir::QPath::Resolved(_, resolved_path_ty) = ty_path + && let Some(func_ty) = func_hir_id_to_func_ty(cx, init.hir_id) + && let Some(return_type) = func_ty_to_return_type(cx, func_ty) +<<<<<<< HEAD + && is_same_type(cx, resolved_path_ty.res, return_type) +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + && is_same_type(cx, resolved_path_ty.res, if is_ref { + return_type.peel_refs() + } else { + return_type + }) +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) { span_lint(cx, REDUNDANT_TYPE_ANNOTATIONS, local.span, "redundant type annotation"); } @@ -173,10 +302,40 @@ impl LateLintPass<'_> for RedundantTypeAnnotations { // When the initialization is a path for example u32::MAX hir::ExprKind::Path(init_path) => { // TODO: check for non primty +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + if let Some(primty) = extract_primty(&ty.kind) + + && let hir::QPath::TypeRelative(init_ty, _) = init_path + && let Some(primty_init) = extract_primty(&init_ty.kind) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + if let hir::TyKind::Path(ty_path) = &ty.kind + && let hir::QPath::Resolved(_, resolved_path_ty) = ty_path + && let hir::def::Res::PrimTy(primty) = resolved_path_ty.res + + && let hir::QPath::TypeRelative(init_ty, _) = init_path + && let hir::TyKind::Path(init_ty_path) = &init_ty.kind + && let hir::QPath::Resolved(_, resolved_init_ty_path) = init_ty_path + && let hir::def::Res::PrimTy(primty_init) = resolved_init_ty_path.res +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= if let Some(primty) = extract_primty(&ty.kind) && let hir::QPath::TypeRelative(init_ty, _) = init_path && let Some(primty_init) = extract_primty(&init_ty.kind) +>>>>>>> 6f26df1c9 (Extract common logic to function) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && primty == primty_init { diff --git a/clippy_lints/src/regex.rs b/clippy_lints/src/regex.rs index b795e4b15bac..5fd4e817a2bf 100644 --- a/clippy_lints/src/regex.rs +++ b/clippy_lints/src/regex.rs @@ -203,7 +203,23 @@ fn check_set<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) { } fn check_regex<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>, utf8: bool) { +<<<<<<< HEAD +<<<<<<< HEAD let mut parser = regex_syntax::ParserBuilder::new().unicode(true).utf8(utf8).build(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + let mut parser = regex_syntax::ParserBuilder::new().unicode(true).utf8(utf8).build(); +======= + let mut parser = regex_syntax::ParserBuilder::new().unicode(true).utf8(!utf8).build(); +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + let mut parser = regex_syntax::ParserBuilder::new().unicode(true).utf8(utf8).build(); +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let mut parser = regex_syntax::ParserBuilder::new().unicode(true).utf8(utf8).build(); +>>>>>>> 615b25c20 (Rebase attempt number 2) if let ExprKind::Lit(lit) = expr.kind { if let LitKind::Str(ref r, style) = lit.node { diff --git a/clippy_lints/src/returns.rs b/clippy_lints/src/returns.rs index 0212deda1460..c162e59f92b9 100644 --- a/clippy_lints/src/returns.rs +++ b/clippy_lints/src/returns.rs @@ -28,7 +28,23 @@ declare_clippy_lint! { /// /// ### Known problems /// In the case of some temporaries, e.g. locks, eliding the variable binding could lead +<<<<<<< HEAD +<<<<<<< HEAD /// to deadlocks. See [this issue](/~https://github.com/rust-lang/rust/issues/37612). +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// to deadlocks. See [this issue](/~https://github.com/rust-lang/rust/issues/37612). +======= + /// to deadlocks. See [rust-lang issue 37612](/~https://github.com/rust-lang/rust/issues/37612). +>>>>>>> 62eb4e7d7 (Bring up Rust lang #37612 as a known problem for let_and_return) +======= + /// to deadlocks. See [this issue](/~https://github.com/rust-lang/rust/issues/37612). +>>>>>>> 6f2497703 (Compact issue link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// to deadlocks. See [this issue](/~https://github.com/rust-lang/rust/issues/37612). +>>>>>>> 615b25c20 (Rebase attempt number 2) /// This could become relevant if the code is later changed to use the code that would have been /// bound without first assigning it to a let-binding. /// diff --git a/clippy_lints/src/semicolon_block.rs b/clippy_lints/src/semicolon_block.rs index 88f295c72ebd..7709ba1d549b 100644 --- a/clippy_lints/src/semicolon_block.rs +++ b/clippy_lints/src/semicolon_block.rs @@ -156,10 +156,20 @@ impl LateLintPass<'_> for SemicolonBlock { kind: StmtKind::Semi(expr), span, .. +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } = stmt else { return; }; +<<<<<<< HEAD +======= + } = stmt else { return }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) self.semicolon_outside_block(cx, block, expr, span); }, StmtKind::Semi(Expr { diff --git a/clippy_lints/src/significant_drop_tightening.rs b/clippy_lints/src/significant_drop_tightening.rs index bf1059a8b290..b8e94a7013d5 100644 --- a/clippy_lints/src/significant_drop_tightening.rs +++ b/clippy_lints/src/significant_drop_tightening.rs @@ -73,7 +73,23 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> { _: hir::def_id::LocalDefId, ) { self.apas.clear(); +<<<<<<< HEAD +<<<<<<< HEAD let initial_dummy_stmt = dummy_stmt_expr(body.value); +======= +<<<<<<< HEAD +<<<<<<< HEAD + let initial_dummy_stmt = dummy_stmt_expr(body.value); +======= + let initial_dummy_stmt = dummy_stmt_expr(&body.value); +>>>>>>> f0619024b (Fix #10413) +======= + let initial_dummy_stmt = dummy_stmt_expr(body.value); +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let initial_dummy_stmt = dummy_stmt_expr(body.value); +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut ap = AuxParams::new(&mut self.apas, &initial_dummy_stmt); StmtsChecker::new(&mut ap, cx, &mut self.seen_types, &mut self.type_cache).visit_body(body); for apa in ap.apas.values() { @@ -92,13 +108,49 @@ impl<'tcx> LateLintPass<'tcx> for SignificantDropTightening<'tcx> { let indent = " ".repeat(indent_of(cx, apa.last_stmt_span).unwrap_or(0)); let init_method = snippet(cx, apa.first_method_span, ".."); let usage_method = snippet(cx, apa.last_method_span, ".."); +<<<<<<< HEAD +<<<<<<< HEAD + let stmt = if apa.last_bind_ident == Ident::empty() { + format!("\n{indent}{init_method}.{usage_method};") + } else { +======= +<<<<<<< HEAD +<<<<<<< HEAD + let stmt = if apa.last_bind_ident == Ident::empty() { + format!("\n{indent}{init_method}.{usage_method};") + } else { +======= + let stmt = if apa.last_bind_ident != Ident::empty() { +>>>>>>> f0619024b (Fix #10413) +======= let stmt = if apa.last_bind_ident == Ident::empty() { format!("\n{indent}{init_method}.{usage_method};") } else { +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let stmt = if apa.last_bind_ident == Ident::empty() { + format!("\n{indent}{init_method}.{usage_method};") + } else { +>>>>>>> 615b25c20 (Rebase attempt number 2) format!( "\n{indent}let {} = {init_method}.{usage_method};", snippet(cx, apa.last_bind_ident.span, ".."), ) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + } else { + format!("\n{indent}{init_method}.{usage_method};") +>>>>>>> f0619024b (Fix #10413) +======= +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }; diag.span_suggestion_verbose( apa.first_stmt_span, @@ -264,7 +316,23 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o fn visit_block(&mut self, block: &'tcx hir::Block<'tcx>) { self.ap.curr_block_hir_id = block.hir_id; self.ap.curr_block_span = block.span; +<<<<<<< HEAD +<<<<<<< HEAD for stmt in block.stmts { +======= +<<<<<<< HEAD +<<<<<<< HEAD + for stmt in block.stmts { +======= + for stmt in block.stmts.iter() { +>>>>>>> f0619024b (Fix #10413) +======= + for stmt in block.stmts { +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for stmt in block.stmts { +>>>>>>> 615b25c20 (Rebase attempt number 2) self.ap.curr_stmt = Cow::Borrowed(stmt); self.visit_stmt(stmt); self.ap.curr_block_hir_id = block.hir_id; @@ -299,6 +367,16 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o } } { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut apa = AuxParamsAttr { first_bind_ident: ident, first_block_hir_id: self.ap.curr_block_hir_id, @@ -315,6 +393,32 @@ impl<'ap, 'lc, 'others, 'stmt, 'tcx> Visitor<'tcx> for StmtsChecker<'ap, 'lc, 'o first_stmt_span: self.ap.curr_stmt.span, ..Default::default() }; +<<<<<<< HEAD +======= +<<<<<<< HEAD + }; +======= + let mut apa = AuxParamsAttr::default(); + apa.first_bind_ident = ident; + apa.first_block_hir_id = self.ap.curr_block_hir_id; + apa.first_block_span = self.ap.curr_block_span; + apa.first_method_span = { + let expr_or_init = expr_or_init(self.cx, expr); + if let hir::ExprKind::MethodCall(_, local_expr, _, span) = expr_or_init.kind { + local_expr.span.to(span) + } + else { + expr_or_init.span + } + }; + apa.first_stmt_span = self.ap.curr_stmt.span; +>>>>>>> f0619024b (Fix #10413) +======= + }; +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) modify_apa_params(&mut apa); let _ = self.ap.apas.insert(hir_id, apa); } else { @@ -446,5 +550,25 @@ fn has_drop(expr: &hir::Expr<'_>, first_bind_ident: &Ident, lcx: &LateContext<'_ } fn is_expensive_expr(expr: &hir::Expr<'_>) -> bool { +<<<<<<< HEAD +<<<<<<< HEAD + !matches!(expr.kind, hir::ExprKind::Path(_)) +======= +<<<<<<< HEAD +<<<<<<< HEAD + !matches!(expr.kind, hir::ExprKind::Path(_)) +======= + if let hir::ExprKind::Path(_) = expr.kind { + false + } else { + true + } +>>>>>>> f0619024b (Fix #10413) +======= + !matches!(expr.kind, hir::ExprKind::Path(_)) +>>>>>>> fc832f0eb (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= !matches!(expr.kind, hir::ExprKind::Path(_)) +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/clippy_lints/src/single_call_fn.rs b/clippy_lints/src/single_call_fn.rs index 7bbe98e0a7f9..075eb8c6a0d3 100644 --- a/clippy_lints/src/single_call_fn.rs +++ b/clippy_lints/src/single_call_fn.rs @@ -1,5 +1,21 @@ use clippy_utils::diagnostics::span_lint_and_help; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::{is_from_proc_macro, is_in_test_function}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::{is_from_proc_macro, is_in_test_function}; +======= +use clippy_utils::is_from_proc_macro; +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +use clippy_utils::{is_from_proc_macro, is_in_test_function}; +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::{is_from_proc_macro, is_in_test_function}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_data_structures::fx::FxHashMap; use rustc_hir::def_id::LocalDefId; use rustc_hir::intravisit::{walk_expr, FnKind, Visitor}; @@ -12,7 +28,23 @@ use rustc_span::Span; declare_clippy_lint! { /// ### What it does +<<<<<<< HEAD +<<<<<<< HEAD + /// Checks for functions that are only used once. Does not lint tests. +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// Checks for functions that are only used once. Does not lint tests. +======= + /// Checks for functions that are only used once. +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= /// Checks for functions that are only used once. Does not lint tests. +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Checks for functions that are only used once. Does not lint tests. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Why is this bad? /// It's usually not, splitting a function into multiple parts often improves readability and in @@ -73,7 +105,22 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn { if self.avoid_breaking_exported_api && cx.effective_visibilities.is_exported(def_id) || in_external_macro(cx.sess(), span) || is_from_proc_macro(cx, &(&kind, body, cx.tcx.local_def_id_to_hir_id(def_id), span)) +<<<<<<< HEAD +<<<<<<< HEAD + || is_in_test_function(cx.tcx, body.value.hir_id) +======= +<<<<<<< HEAD +<<<<<<< HEAD + || is_in_test_function(cx.tcx, body.value.hir_id) +======= +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= + || is_in_test_function(cx.tcx, body.value.hir_id) +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= || is_in_test_function(cx.tcx, body.value.hir_id) +>>>>>>> 615b25c20 (Rebase attempt number 2) { return; } @@ -89,14 +136,46 @@ impl<'tcx> LateLintPass<'tcx> for SingleCallFn { cx.tcx.hir().visit_all_item_likes_in_crate(&mut v); for usage in self.def_id_to_usage.values() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let single_call_fn_span = usage.0; + if let [caller_span] = *usage.1 { + span_lint_and_help( + cx, + SINGLE_CALL_FN, + single_call_fn_span, + "this function is only used once", + Some(caller_span), +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let fn_span = usage.0; + if let [usage] = *usage.1 { +======= let single_call_fn_span = usage.0; if let [caller_span] = *usage.1 { +>>>>>>> a8605269b (add test for closures) span_lint_and_help( cx, SINGLE_CALL_FN, single_call_fn_span, "this function is only used once", +<<<<<<< HEAD + Some(usage), +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= Some(caller_span), +>>>>>>> a8605269b (add test for closures) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "used here", ); } diff --git a/clippy_lints/src/single_range_in_vec_init.rs b/clippy_lints/src/single_range_in_vec_init.rs index 321c89889887..7712bef6eea6 100644 --- a/clippy_lints/src/single_range_in_vec_init.rs +++ b/clippy_lints/src/single_range_in_vec_init.rs @@ -1,9 +1,42 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +use clippy_utils::{ +<<<<<<< HEAD +<<<<<<< HEAD + diagnostics::span_lint_and_then, get_trait_def_id, higher::VecArgs, macros::root_macro_call_first_node, + source::snippet_opt, ty::implements_trait, +======= + diagnostics::span_lint_and_then, + get_trait_def_id, + higher::VecArgs, + macros::root_macro_call_first_node, + source::{snippet_opt, snippet_with_applicability}, + ty::implements_trait, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + diagnostics::span_lint_and_then, get_trait_def_id, higher::VecArgs, macros::root_macro_call_first_node, + source::snippet_opt, ty::implements_trait, +>>>>>>> 830d307d0 (refactor a bit) +}; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::get_trait_def_id; use clippy_utils::higher::VecArgs; use clippy_utils::macros::root_macro_call_first_node; use clippy_utils::source::snippet_opt; use clippy_utils::ty::implements_trait; +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_ast::{LitIntType, LitKind, UintTy}; use rustc_errors::Applicability; use rustc_hir::{Expr, ExprKind, LangItem, QPath}; @@ -16,9 +49,33 @@ declare_clippy_lint! { /// Checks for `Vec` or array initializations that contain only one range. /// /// ### Why is this bad? +<<<<<<< HEAD +<<<<<<< HEAD /// This is almost always incorrect, as it will result in a `Vec` that has only one element. /// Almost always, the programmer intended for it to include all elements in the range or for /// the end of the range to be the length instead. +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// This is almost always incorrect, as it will result in a `Vec` that has only one element. + /// Almost always, the programmer intended for it to include all elements in the range or for + /// the end of the range to be the length instead. +======= + /// This is almost always incorrect, as it will result in a `Vec` that has only element. Almost + /// always, the programmer intended for it to include all elements in the range or for the end + /// of the range to be the length instead. +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + /// This is almost always incorrect, as it will result in a `Vec` that has only one element. + /// Almost always, the programmer intended for it to include all elements in the range or for + /// the end of the range to be the length instead. +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// This is almost always incorrect, as it will result in a `Vec` that has only one element. + /// Almost always, the programmer intended for it to include all elements in the range or for + /// the end of the range to be the length instead. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Example /// ```rust @@ -73,8 +130,28 @@ impl LateLintPass<'_> for SingleRangeInVecInit { // ^^^^^^ ^^^^^^^ // span: `vec![0..200]` or `[0..200]` // ^^^^^^^^^^^^ ^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD + // suggested_type: What to print, "an array" or "a `Vec`" + let (inner_expr, span, suggested_type) = if let ExprKind::Array([inner_expr]) = expr.kind +======= +<<<<<<< HEAD +<<<<<<< HEAD // suggested_type: What to print, "an array" or "a `Vec`" let (inner_expr, span, suggested_type) = if let ExprKind::Array([inner_expr]) = expr.kind +======= + // kind: What to print, an array or a `Vec` + let (inner_expr, span, kind) = if let ExprKind::Array([inner_expr]) = expr.kind +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + // suggested_type: What to print, "an array" or "a `Vec`" + let (inner_expr, span, suggested_type) = if let ExprKind::Array([inner_expr]) = expr.kind +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // suggested_type: What to print, "an array" or "a `Vec`" + let (inner_expr, span, suggested_type) = if let ExprKind::Array([inner_expr]) = expr.kind +>>>>>>> 615b25c20 (Rebase attempt number 2) && !expr.span.from_expansion() { (inner_expr, expr.span, SuggestedType::Array) @@ -94,11 +171,40 @@ impl LateLintPass<'_> for SingleRangeInVecInit { && let ty = cx.typeck_results().expr_ty(start.expr) && let Some(snippet) = snippet_opt(cx, span) // `is_from_proc_macro` will skip any `vec![]`. Let's not! +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && snippet.starts_with(suggested_type.starts_with()) && snippet.ends_with(suggested_type.ends_with()) && let Some(start_snippet) = snippet_opt(cx, start.span) && let Some(end_snippet) = snippet_opt(cx, end.span) { +<<<<<<< HEAD +======= +<<<<<<< HEAD + { +======= + && snippet.starts_with(kind.starts_with()) + && snippet.ends_with(kind.ends_with()) + { + let mut app = Applicability::MaybeIncorrect; + let start_snippet = snippet_with_applicability(cx, start.span, "...", &mut app); + let end_snippet = snippet_with_applicability(cx, end.span, "...", &mut app); + +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + { +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let should_emit_every_value = if let Some(step_def_id) = get_trait_def_id(cx, &["core", "iter", "Step"]) && implements_trait(cx, ty, step_def_id, &[]) { @@ -122,23 +228,87 @@ impl LateLintPass<'_> for SingleRangeInVecInit { cx, SINGLE_RANGE_IN_VEC_INIT, span, +<<<<<<< HEAD +<<<<<<< HEAD + &format!("{suggested_type} of `Range` that is only one element"), +======= +<<<<<<< HEAD +<<<<<<< HEAD + &format!("{suggested_type} of `Range` that is only one element"), +======= + &format!("{kind} of `Range` that is only one element"), +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= &format!("{suggested_type} of `Range` that is only one element"), +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + &format!("{suggested_type} of `Range` that is only one element"), +>>>>>>> 615b25c20 (Rebase attempt number 2) |diag| { if should_emit_every_value { diag.span_suggestion( span, +<<<<<<< HEAD +<<<<<<< HEAD + "if you wanted a `Vec` that contains the entire range, try", + format!("({start_snippet}..{end_snippet}).collect::>()"), + Applicability::MaybeIncorrect, +======= +<<<<<<< HEAD +<<<<<<< HEAD + "if you wanted a `Vec` that contains the entire range, try", + format!("({start_snippet}..{end_snippet}).collect::>()"), + Applicability::MaybeIncorrect, +======= + "if you wanted a `Vec` that contains every value in the range, try", + format!("({start_snippet}..{end_snippet}).collect::>()"), + app, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + "if you wanted a `Vec` that contains the entire range, try", + format!("({start_snippet}..{end_snippet}).collect::>()"), + Applicability::MaybeIncorrect, +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= "if you wanted a `Vec` that contains the entire range, try", format!("({start_snippet}..{end_snippet}).collect::>()"), Applicability::MaybeIncorrect, +>>>>>>> 615b25c20 (Rebase attempt number 2) ); } if should_emit_of_len { diag.span_suggestion( inner_expr.span, +<<<<<<< HEAD +<<<<<<< HEAD + format!("if you wanted {suggested_type} of len {end_snippet}, try"), + format!("{start_snippet}; {end_snippet}"), + Applicability::MaybeIncorrect, +======= +<<<<<<< HEAD +<<<<<<< HEAD + format!("if you wanted {suggested_type} of len {end_snippet}, try"), + format!("{start_snippet}; {end_snippet}"), + Applicability::MaybeIncorrect, +======= + format!("if you wanted {kind} of len {end_snippet}, try"), + format!("{start_snippet}; {end_snippet}"), + app, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + format!("if you wanted {suggested_type} of len {end_snippet}, try"), + format!("{start_snippet}; {end_snippet}"), + Applicability::MaybeIncorrect, +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= format!("if you wanted {suggested_type} of len {end_snippet}, try"), format!("{start_snippet}; {end_snippet}"), Applicability::MaybeIncorrect, +>>>>>>> 615b25c20 (Rebase attempt number 2) ); } }, diff --git a/clippy_lints/src/trait_bounds.rs b/clippy_lints/src/trait_bounds.rs index 6db330dfa617..37d9041f0428 100644 --- a/clippy_lints/src/trait_bounds.rs +++ b/clippy_lints/src/trait_bounds.rs @@ -230,9 +230,34 @@ impl<'tcx> LateLintPass<'tcx> for TraitBounds { impl TraitBounds { /// Is the given bound a `?Sized` bound, and is combining it (i.e. `T: X + ?Sized`) an error on +<<<<<<< HEAD +<<<<<<< HEAD /// this MSRV? See for details. fn cannot_combine_maybe_bound(&self, cx: &LateContext<'_>, bound: &GenericBound<'_>) -> bool { if !self.msrv.meets(msrvs::MAYBE_BOUND_IN_WHERE) +======= +<<<<<<< HEAD +<<<<<<< HEAD + /// this MSRV? See for details. + fn cannot_combine_maybe_bound(&self, cx: &LateContext<'_>, bound: &GenericBound<'_>) -> bool { + if !self.msrv.meets(msrvs::MAYBE_BOUND_IN_WHERE) +<<<<<<< HEAD +======= + /// this MSRV? See /~https://github.com/rust-lang/rust-clippy/issues/8772 for details. +======= + /// this MSRV? See for details. +>>>>>>> 765a6e4a9 (put issue link between <>) + fn cannot_combine_maybe_bound(&self, cx: &LateContext<'_>, bound: &GenericBound<'_>) -> bool { + if !self.msrv.meets(msrvs::COMBINED_MAYBE_BOUND) +>>>>>>> 87c28b946 ([`type_repetition_in_bounds`]: respect msrv for combining maybe bounds) +======= +>>>>>>> 33b6d0d20 (rename MSRV alias, add MSRV to lint doc) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// this MSRV? See for details. + fn cannot_combine_maybe_bound(&self, cx: &LateContext<'_>, bound: &GenericBound<'_>) -> bool { + if !self.msrv.meets(msrvs::MAYBE_BOUND_IN_WHERE) +>>>>>>> 615b25c20 (Rebase attempt number 2) && let GenericBound::Trait(tr, TraitBoundModifier::Maybe) = bound { cx.tcx.lang_items().get(LangItem::Sized) == tr.trait_ref.path.res.opt_def_id() @@ -272,10 +297,43 @@ impl TraitBounds { if p.origin != PredicateOrigin::ImplTrait; if p.bounds.len() as u64 <= self.max_trait_bounds; if !p.span.from_expansion(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let bounds = p.bounds.iter().filter(|b| !self.cannot_combine_maybe_bound(cx, b)).collect::>(); + if !bounds.is_empty(); + if let Some(ref v) = map.insert(SpanlessTy { ty: p.bounded_ty, cx }, bounds); + if !is_from_proc_macro(cx, p.bounded_ty); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + if let Some(ref v) = map.insert( + SpanlessTy { ty: p.bounded_ty, cx }, + p.bounds.iter().collect::>() + ); +<<<<<<< HEAD + let bounded_ty = snippet(cx, p.bounded_ty.span, "_"); + if let TyKind::Path(qpath) = p.bounded_ty.kind; + if format!("{}:", rustc_hir_pretty::qpath_to_string(&qpath)) == format!("{bounded_ty}:"); + +>>>>>>> 6ea7cd8ec (Fix #10504, don't lint on derived code) +======= +======= let bounds = p.bounds.iter().filter(|b| !self.cannot_combine_maybe_bound(cx, b)).collect::>(); if !bounds.is_empty(); if let Some(ref v) = map.insert(SpanlessTy { ty: p.bounded_ty, cx }, bounds); +>>>>>>> 87c28b946 ([`type_repetition_in_bounds`]: respect msrv for combining maybe bounds) if !is_from_proc_macro(cx, p.bounded_ty); +>>>>>>> a434a7715 (`impl WithSearchPat for Ty`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) then { let trait_bounds = v .iter() diff --git a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs index 4ae4359eea0b..3bfd7f745cff 100644 --- a/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs +++ b/clippy_lints/src/transmute/transmute_ptr_to_ptr.rs @@ -24,7 +24,15 @@ pub(super) fn check<'tcx>( "transmute from a pointer to a pointer", |diag| { if let Some(arg) = sugg::Sugg::hir_opt(cx, arg) { +<<<<<<< HEAD +<<<<<<< HEAD let sugg = arg.as_ty(Ty::new_ptr(cx.tcx, *to_ty)); +======= + let sugg = arg.as_ty(Ty::new_ptr(cx.tcx,*to_ty)); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let sugg = arg.as_ty(Ty::new_ptr(cx.tcx, *to_ty)); +>>>>>>> 615b25c20 (Rebase attempt number 2) diag.span_suggestion(e.span, "try", sugg, Applicability::Unspecified); } }, diff --git a/clippy_lints/src/transmute/useless_transmute.rs b/clippy_lints/src/transmute/useless_transmute.rs index 088c8fda87a3..bf1f303d1d9d 100644 --- a/clippy_lints/src/transmute/useless_transmute.rs +++ b/clippy_lints/src/transmute/useless_transmute.rs @@ -43,7 +43,15 @@ pub(super) fn check<'tcx>( let sugg = if *ptr_ty == rty_and_mut { arg.as_ty(to_ty) } else { +<<<<<<< HEAD +<<<<<<< HEAD arg.as_ty(Ty::new_ptr(cx.tcx, rty_and_mut)).as_ty(to_ty) +======= + arg.as_ty(Ty::new_ptr(cx.tcx,rty_and_mut)).as_ty(to_ty) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + arg.as_ty(Ty::new_ptr(cx.tcx, rty_and_mut)).as_ty(to_ty) +>>>>>>> 615b25c20 (Rebase attempt number 2) }; diag.span_suggestion(e.span, "try", sugg, Applicability::Unspecified); diff --git a/clippy_lints/src/tuple_array_conversions.rs b/clippy_lints/src/tuple_array_conversions.rs index 2e00ed042a8b..34b890303b69 100644 --- a/clippy_lints/src/tuple_array_conversions.rs +++ b/clippy_lints/src/tuple_array_conversions.rs @@ -1,8 +1,46 @@ +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::msrvs::{self, Msrv}; use clippy_utils::{is_from_proc_macro, path_to_local}; use rustc_ast::LitKind; use rustc_hir::{Expr, ExprKind, HirId, Node, Pat}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +use clippy_utils::{ + diagnostics::span_lint_and_help, + is_from_proc_macro, + msrvs::{self, Msrv}, + path_to_local, +}; +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use clippy_utils::diagnostics::span_lint_and_help; +use clippy_utils::msrvs::{self, Msrv}; +use clippy_utils::{is_from_proc_macro, path_to_local}; +use rustc_ast::LitKind; +use rustc_hir::{Expr, ExprKind, HirId, Node, Pat}; +<<<<<<< HEAD +======= +use itertools::Itertools; +use rustc_ast::LitKind; +use rustc_hir::{Expr, ExprKind, Node, Pat}; +>>>>>>> 95b24d44a (Fix FP) +======= +use rustc_ast::LitKind; +use rustc_hir::{Expr, ExprKind, HirId, Node, Pat}; +>>>>>>> 826edd75e (heavily refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_lint::{LateContext, LateLintPass, LintContext}; use rustc_middle::lint::in_external_macro; use rustc_middle::ty; @@ -14,8 +52,49 @@ declare_clippy_lint! { /// Checks for tuple<=>array conversions that are not done with `.into()`. /// /// ### Why is this bad? +<<<<<<< HEAD +<<<<<<< HEAD + /// It may be unnecessary complexity. `.into()` works for converting tuples + /// <=> arrays of up to 12 elements and may convey intent more clearly. +======= +<<<<<<< HEAD + /// It's unnecessary complexity. `.into()` works for tuples<=>arrays at or below 12 elements and + /// conveys the intent a lot better, while also leaving less room for hard to spot bugs! +<<<<<<< HEAD +======= +use clippy_utils::{diagnostics::span_lint_and_help, is_from_proc_macro, path_to_local}; +use rustc_hir::*; +======= +use itertools::Itertools; +use rustc_hir::{Expr, ExprKind, Node, Pat}; +>>>>>>> b1acbde61 (Add msrv check and make test pass) +use rustc_lint::{LateContext, LateLintPass, LintContext}; +use rustc_middle::{lint::in_external_macro, ty}; +use rustc_session::{declare_tool_lint, impl_lint_pass}; +use std::iter::once; + +declare_clippy_lint! { + /// ### What it does + /// Checks for tuple<=>array conversions that are not done with `.into()`. + /// + /// ### Why is this bad? +<<<<<<< HEAD +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + /// It's overly complex. `.into()` works for tuples<=>arrays with less than 13 elements and + /// conveys the intent a lot better, while also leaving less room for bugs! +>>>>>>> b1acbde61 (Add msrv check and make test pass) +======= +>>>>>>> 826edd75e (heavily refactor) +======= + /// It may be unnecessary complexity. `.into()` works for converting tuples + /// <=> arrays of up to 12 elements and may convey intent more clearly. +>>>>>>> 4102a309d ([`tuple_array_conversions`]: move from `complexity` to `nursery`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= /// It may be unnecessary complexity. `.into()` works for converting tuples /// <=> arrays of up to 12 elements and may convey intent more clearly. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Example /// ```rust,ignore @@ -29,7 +108,23 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.72.0"] pub TUPLE_ARRAY_CONVERSIONS, +<<<<<<< HEAD +<<<<<<< HEAD + pedantic, +======= +<<<<<<< HEAD + complexity, +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +======= + pedantic, +>>>>>>> 4102a309d ([`tuple_array_conversions`]: move from `complexity` to `nursery`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= pedantic, +>>>>>>> 615b25c20 (Rebase attempt number 2) "checks for tuple<=>array conversions that are not done with `.into()`" } impl_lint_pass!(TupleArrayConversions => [TUPLE_ARRAY_CONVERSIONS]); @@ -37,6 +132,139 @@ impl_lint_pass!(TupleArrayConversions => [TUPLE_ARRAY_CONVERSIONS]); #[derive(Clone)] pub struct TupleArrayConversions { pub msrv: Msrv, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +} + +impl LateLintPass<'_> for TupleArrayConversions { + fn check_expr<'tcx>(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { + if !in_external_macro(cx.sess(), expr.span) && self.msrv.meets(msrvs::TUPLE_ARRAY_CONVERSIONS) { + match expr.kind { + ExprKind::Array(elements) if (1..=12).contains(&elements.len()) => check_array(cx, expr, elements), + ExprKind::Tup(elements) if (1..=12).contains(&elements.len()) => check_tuple(cx, expr, elements), + _ => {}, + } + } + } + + extract_msrv_attr!(LateContext); +} + +#[expect( + clippy::blocks_in_if_conditions, + reason = "not a FP, but this is much easier to understand" +)] +fn check_array<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: &'tcx [Expr<'tcx>]) { + if should_lint( + cx, + elements, + // This is cursed. + Some, + |(first_id, local)| { + if let Node::Pat(pat) = local + && let parent = parent_pat(cx, pat) + && parent.hir_id == first_id + { + return matches!( + cx.typeck_results().pat_ty(parent).peel_refs().kind(), + ty::Tuple(len) if len.len() == elements.len() + ); + } + + false + }, + ) || should_lint( + cx, + elements, + |(i, expr)| { + if let ExprKind::Field(path, field) = expr.kind && field.as_str() == i.to_string() { + return Some((i, path)); + }; + + None + }, + |(first_id, local)| { + if let Node::Pat(pat) = local + && let parent = parent_pat(cx, pat) + && parent.hir_id == first_id + { + return matches!( + cx.typeck_results().pat_ty(parent).peel_refs().kind(), + ty::Tuple(len) if len.len() == elements.len() + ); + } + + false + }, + ) { + emit_lint(cx, expr, ToType::Array); + } +} + +#[expect( + clippy::blocks_in_if_conditions, + reason = "not a FP, but this is much easier to understand" +)] +#[expect(clippy::cast_possible_truncation)] +fn check_tuple<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: &'tcx [Expr<'tcx>]) { + if should_lint(cx, elements, Some, |(first_id, local)| { + if let Node::Pat(pat) = local + && let parent = parent_pat(cx, pat) + && parent.hir_id == first_id + { + return matches!( + cx.typeck_results().pat_ty(parent).peel_refs().kind(), + ty::Array(_, len) if len.eval_target_usize(cx.tcx, cx.param_env) as usize == elements.len() + ); + } + + false + }) || should_lint( + cx, + elements, + |(i, expr)| { + if let ExprKind::Index(path, index) = expr.kind + && let ExprKind::Lit(lit) = index.kind + && let LitKind::Int(val, _) = lit.node + && val as usize == i + { + return Some((i, path)); + }; + + None + }, + |(first_id, local)| { + if let Node::Pat(pat) = local + && let parent = parent_pat(cx, pat) + && parent.hir_id == first_id + { + return matches!( + cx.typeck_results().pat_ty(parent).peel_refs().kind(), + ty::Array(_, len) if len.eval_target_usize(cx.tcx, cx.param_env) as usize == elements.len() + ); + } + + false + }, + ) { + emit_lint(cx, expr, ToType::Tuple); + } +} + +/// Walks up the `Pat` until it's reached the final containing `Pat`. +fn parent_pat<'tcx>(cx: &LateContext<'tcx>, start: &'tcx Pat<'tcx>) -> &'tcx Pat<'tcx> { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + "default lint description" +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) } impl LateLintPass<'_> for TupleArrayConversions { @@ -155,7 +383,15 @@ fn check_tuple<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, elements: & } /// Walks up the `Pat` until it's reached the final containing `Pat`. +<<<<<<< HEAD +fn backtrack_pat<'tcx>(cx: &LateContext<'tcx>, start: &'tcx Pat<'tcx>) -> &'tcx Pat<'tcx> { +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= fn parent_pat<'tcx>(cx: &LateContext<'tcx>, start: &'tcx Pat<'tcx>) -> &'tcx Pat<'tcx> { +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut end = start; for (_, node) in cx.tcx.hir().parent_iter(start.hir_id) { if let Node::Pat(pat) = node { @@ -167,6 +403,32 @@ fn parent_pat<'tcx>(cx: &LateContext<'tcx>, start: &'tcx Pat<'tcx>) -> &'tcx Pat end } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +fn path_to_locals<'tcx>( + cx: &LateContext<'tcx>, + exprs: impl IntoIterator>, +) -> Option>> { +======= +fn path_to_locals<'tcx>(cx: &LateContext<'tcx>, exprs: &[&'tcx Expr<'tcx>]) -> Option>> { +>>>>>>> b1acbde61 (Add msrv check and make test pass) + exprs + .iter() + .map(|element| path_to_local(element).and_then(|local| cx.tcx.hir().find(local))) + .collect() +} + +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= +>>>>>>> 826edd75e (heavily refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Clone, Copy)] enum ToType { Array, @@ -174,12 +436,38 @@ enum ToType { } impl ToType { +<<<<<<< HEAD +<<<<<<< HEAD fn msg(self) -> &'static str { +======= +<<<<<<< HEAD +<<<<<<< HEAD + fn msg(self) -> &'static str { +======= + fn help(self) -> &'static str { +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + fn msg(self) -> &'static str { +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + fn msg(self) -> &'static str { +>>>>>>> 615b25c20 (Rebase attempt number 2) match self { ToType::Array => "it looks like you're trying to convert a tuple to an array", ToType::Tuple => "it looks like you're trying to convert an array to a tuple", } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn help(self) -> &'static str { match self { @@ -187,6 +475,17 @@ impl ToType { ToType::Tuple => "use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed", } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn emit_lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, to_type: ToType) -> bool { @@ -195,9 +494,33 @@ fn emit_lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, to_type: ToTy cx, TUPLE_ARRAY_CONVERSIONS, expr.span, +<<<<<<< HEAD +<<<<<<< HEAD + to_type.msg(), + None, + to_type.help(), +======= +<<<<<<< HEAD +<<<<<<< HEAD + to_type.msg(), + None, + to_type.help(), +======= + to_type.help(), + None, + "use `.into()` instead", +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + to_type.msg(), + None, + to_type.help(), +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= to_type.msg(), None, to_type.help(), +>>>>>>> 615b25c20 (Rebase attempt number 2) ); return true; @@ -205,6 +528,16 @@ fn emit_lint<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, to_type: ToTy false } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 826edd75e (heavily refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn should_lint<'tcx>( cx: &LateContext<'tcx>, @@ -231,3 +564,14 @@ fn should_lint<'tcx>( false } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= +>>>>>>> 826edd75e (heavily refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/clippy_lints/src/undocumented_unsafe_blocks.rs b/clippy_lints/src/undocumented_unsafe_blocks.rs index f2ef602012f7..9a8e85cf8b53 100644 --- a/clippy_lints/src/undocumented_unsafe_blocks.rs +++ b/clippy_lints/src/undocumented_unsafe_blocks.rs @@ -95,6 +95,14 @@ declare_clippy_lint! { #[derive(Copy, Clone)] pub struct UndocumentedUnsafeBlocks { accept_comment_above_statement: bool, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) accept_comment_above_attributes: bool, } @@ -103,6 +111,27 @@ impl UndocumentedUnsafeBlocks { Self { accept_comment_above_statement, accept_comment_above_attributes, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= + accept_comment_above_attributes: bool, +>>>>>>> cc2e49f69 (allow safety comment above attributes) +} + +impl UndocumentedUnsafeBlocks { + pub fn new(accept_comment_above_statement: bool, accept_comment_above_attributes: bool) -> Self { + Self { + accept_comment_above_statement, +<<<<<<< HEAD +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= + accept_comment_above_attributes, +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } @@ -116,12 +145,34 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks { && !is_lint_allowed(cx, UNDOCUMENTED_UNSAFE_BLOCKS, block.hir_id) && !is_unsafe_from_proc_macro(cx, block.span) && !block_has_safety_comment(cx, block.span) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && !block_parents_have_safety_comment( self.accept_comment_above_statement, self.accept_comment_above_attributes, cx, block.hir_id, ) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + && !block_parents_have_safety_comment(self.accept_comment_above_statement, cx, block.hir_id) +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) { let source_map = cx.tcx.sess.source_map(); let span = if source_map.is_multiline(block.span) { @@ -336,7 +387,22 @@ fn is_unsafe_from_proc_macro(cx: &LateContext<'_>, span: Span) -> bool { // has a safety comment fn block_parents_have_safety_comment( accept_comment_above_statement: bool, +<<<<<<< HEAD +<<<<<<< HEAD accept_comment_above_attributes: bool, +======= +<<<<<<< HEAD +<<<<<<< HEAD + accept_comment_above_attributes: bool, +======= +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= + accept_comment_above_attributes: bool, +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + accept_comment_above_attributes: bool, +>>>>>>> 615b25c20 (Rebase attempt number 2) cx: &LateContext<'_>, id: hir::HirId, ) -> bool { @@ -352,6 +418,16 @@ fn block_parents_have_safety_comment( }), ) = get_parent_node(cx.tcx, expr.hir_id) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let hir_id = match get_parent_node(cx.tcx, expr.hir_id) { Some(Node::Local(hir::Local { hir_id, .. })) => *hir_id, Some(Node::Item(hir::Item { owner_id, .. })) => { @@ -360,6 +436,37 @@ fn block_parents_have_safety_comment( _ => unreachable!(), }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // if unsafe block is part of a let/const/static statement, + // and accept_comment_above_statement is set to true + // we accept the safety comment in the line the precedes this statement. + accept_comment_above_statement + && span_with_attrs_in_body_has_safety_comment( + cx, + *span, + hir_id, + accept_comment_above_attributes, + ) + } else { + !is_branchy(expr) + && span_with_attrs_in_body_has_safety_comment( + cx, + expr.span, + expr.hir_id, + accept_comment_above_attributes, + ) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) // if unsafe block is part of a let/const/static statement, // and accept_comment_above_statement is set to true // we accept the safety comment in the line the precedes this statement. @@ -371,6 +478,10 @@ fn block_parents_have_safety_comment( accept_comment_above_attributes, ) } else { +<<<<<<< HEAD + !is_branchy(expr) && span_in_body_has_safety_comment(cx, expr.span) +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= !is_branchy(expr) && span_with_attrs_in_body_has_safety_comment( cx, @@ -378,6 +489,10 @@ fn block_parents_have_safety_comment( expr.hir_id, accept_comment_above_attributes, ) +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } }, Node::Stmt(hir::Stmt { diff --git a/clippy_lints/src/unnecessary_box_returns.rs b/clippy_lints/src/unnecessary_box_returns.rs index ed2ef506381f..31d760de4a54 100644 --- a/clippy_lints/src/unnecessary_box_returns.rs +++ b/clippy_lints/src/unnecessary_box_returns.rs @@ -116,9 +116,19 @@ impl LateLintPass<'_> for UnnecessaryBoxReturns { fn check_impl_item(&mut self, cx: &LateContext<'_>, item: &rustc_hir::ImplItem<'_>) { // Ignore implementations of traits, because the lint should be on the // trait, not on the implementation of it. +<<<<<<< HEAD +<<<<<<< HEAD let Node::Item(parent) = cx.tcx.hir().get_parent(item.hir_id()) else { return; }; +======= + let Node::Item(parent) = cx.tcx.hir().get_parent(item.hir_id()) else { return }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let Node::Item(parent) = cx.tcx.hir().get_parent(item.hir_id()) else { + return; + }; +>>>>>>> 615b25c20 (Rebase attempt number 2) let ItemKind::Impl(parent) = parent.kind else { return }; if parent.of_trait.is_some() { return; diff --git a/clippy_lints/src/unused_async.rs b/clippy_lints/src/unused_async.rs index 5e42cf7e4f3f..96ef63ccdf1a 100644 --- a/clippy_lints/src/unused_async.rs +++ b/clippy_lints/src/unused_async.rs @@ -1,5 +1,26 @@ +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::diagnostics::span_lint_and_then; use clippy_utils::is_def_id_trait_method; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::is_def_id_trait_method; +<<<<<<< HEAD +======= +use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_then}; +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= +use clippy_utils::diagnostics::span_lint_and_then; +>>>>>>> 3eeeaa2bc (remove old span_lint) +======= +>>>>>>> b713cd594 (move `is_in_trait_method` to utils and rename) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::diagnostics::span_lint_and_then; +use clippy_utils::is_def_id_trait_method; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::intravisit::{walk_body, walk_expr, walk_fn, FnKind, Visitor}; use rustc_hir::{Body, Expr, ExprKind, FnDecl, YieldSource}; use rustc_lint::{LateContext, LateLintPass}; @@ -45,7 +66,23 @@ struct AsyncFnVisitor<'a, 'tcx> { found_await: bool, /// Also keep track of `await`s in nested async blocks so we can mention /// it in a note +<<<<<<< HEAD +<<<<<<< HEAD await_in_async_block: Option, +======= +<<<<<<< HEAD +<<<<<<< HEAD + await_in_async_block: Option, +======= + found_await_in_async_block: bool, +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + await_in_async_block: Option, +>>>>>>> 8ef6240af (point to `await` expr in note) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + await_in_async_block: Option, +>>>>>>> 615b25c20 (Rebase attempt number 2) async_depth: usize, } @@ -56,8 +93,28 @@ impl<'a, 'tcx> Visitor<'tcx> for AsyncFnVisitor<'a, 'tcx> { if let ExprKind::Yield(_, YieldSource::Await { .. }) = ex.kind { if self.async_depth == 1 { self.found_await = true; +<<<<<<< HEAD +<<<<<<< HEAD + } else if self.await_in_async_block.is_none() { + self.await_in_async_block = Some(ex.span); +======= +<<<<<<< HEAD +<<<<<<< HEAD } else if self.await_in_async_block.is_none() { self.await_in_async_block = Some(ex.span); +======= + } else { + self.found_await_in_async_block = true; +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + } else if self.await_in_async_block.is_none() { + self.await_in_async_block = Some(ex.span); +>>>>>>> 8ef6240af (point to `await` expr in note) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + } else if self.await_in_async_block.is_none() { + self.await_in_async_block = Some(ex.span); +>>>>>>> 615b25c20 (Rebase attempt number 2) } } walk_expr(self, ex); @@ -92,16 +149,60 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync { span: Span, def_id: LocalDefId, ) { +<<<<<<< HEAD +<<<<<<< HEAD + if !span.from_expansion() && fn_kind.asyncness().is_async() && !is_def_id_trait_method(cx, def_id) { +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD if !span.from_expansion() && fn_kind.asyncness().is_async() && !is_def_id_trait_method(cx, def_id) { +======= + if !span.from_expansion() && fn_kind.asyncness().is_async() { +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + if !span.from_expansion() && fn_kind.asyncness().is_async() && !is_in_trait_impl(cx, def_id) { +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +======= + if !span.from_expansion() && fn_kind.asyncness().is_async() && !is_def_id_trait_method(cx, def_id) { +>>>>>>> b713cd594 (move `is_in_trait_method` to utils and rename) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + if !span.from_expansion() && fn_kind.asyncness().is_async() && !is_def_id_trait_method(cx, def_id) { +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut visitor = AsyncFnVisitor { cx, found_await: false, async_depth: 0, +<<<<<<< HEAD +<<<<<<< HEAD + await_in_async_block: None, +======= +<<<<<<< HEAD +<<<<<<< HEAD + await_in_async_block: None, +======= + found_await_in_async_block: false, +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + await_in_async_block: None, +>>>>>>> 8ef6240af (point to `await` expr in note) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= await_in_async_block: None, +>>>>>>> 615b25c20 (Rebase attempt number 2) }; walk_fn(&mut visitor, fn_kind, fn_decl, body.id(), def_id); if !visitor.found_await { span_lint_and_then( +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) cx, UNUSED_ASYNC, span, diff --git a/clippy_lints/src/useless_conversion.rs b/clippy_lints/src/useless_conversion.rs index 9e07da8995b5..5c994a88f162 100644 --- a/clippy_lints/src/useless_conversion.rs +++ b/clippy_lints/src/useless_conversion.rs @@ -67,6 +67,16 @@ fn into_iter_bound(cx: &LateContext<'_>, fn_did: DefId, into_iter_did: DefId, pa .iter() .find_map(|&(ref pred, span)| { if let ty::ClauseKind::Trait(tr) = pred.kind().skip_binder() +<<<<<<< HEAD +======= +<<<<<<< HEAD + if let ty::ClauseKind::Trait(tr) = pred.kind().skip_binder() +======= + if let ty::PredicateKind::Clause(ty::Clause::Trait(tr)) = pred.kind().skip_binder() +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) && tr.def_id() == into_iter_did && tr.self_ty().is_param(param_index) { @@ -92,6 +102,16 @@ fn into_iter_call<'hir>(cx: &LateContext<'_>, expr: &'hir Expr<'hir>) -> Option< /// Same as [`into_iter_call`], but tries to look for the innermost `.into_iter()` call, e.g.: /// `foo.into_iter().into_iter()` /// ^^^ we want this expression +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn into_iter_deep_call<'hir>(cx: &LateContext<'_>, mut expr: &'hir Expr<'hir>) -> (&'hir Expr<'hir>, usize) { let mut depth = 0; while let Some(recv) = into_iter_call(cx, expr) { @@ -99,6 +119,28 @@ fn into_iter_deep_call<'hir>(cx: &LateContext<'_>, mut expr: &'hir Expr<'hir>) - depth += 1; } (expr, depth) +<<<<<<< HEAD +======= +<<<<<<< HEAD + } + (expr, depth) +======= +fn into_iter_deep_call<'hir>(cx: &LateContext<'_>, mut expr: &'hir Expr<'hir>) -> Option<&'hir Expr<'hir>> { + loop { + if let Some(recv) = into_iter_call(cx, expr) { + expr = recv; + } else { + return Some(expr); + } + } +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + } + (expr, depth) +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } #[expect(clippy::too_many_lines)] @@ -168,6 +210,14 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { && let Some(&into_iter_param) = sig.inputs().get(kind.param_pos(arg_pos)) && let ty::Param(param) = into_iter_param.kind() && let Some(span) = into_iter_bound(cx, parent_fn_did, into_iter_did, param.index) +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) { // Get the "innermost" `.into_iter()` call, e.g. given this expression: // `foo.into_iter().into_iter()` @@ -175,12 +225,51 @@ impl<'tcx> LateLintPass<'tcx> for UselessConversion { let (into_iter_recv, depth) = into_iter_deep_call(cx, into_iter_recv); let plural = if depth == 0 { "" } else { "s" }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // Get the "innermost" `.into_iter()` call, e.g. given this expression: + // `foo.into_iter().into_iter()` + // ^^^ + // We want this span + && let Some(into_iter_recv) = into_iter_deep_call(cx, into_iter_recv) + { +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + { + // Get the "innermost" `.into_iter()` call, e.g. given this expression: + // `foo.into_iter().into_iter()` + // ^^^ + let (into_iter_recv, depth) = into_iter_deep_call(cx, into_iter_recv); + + let plural = if depth == 0 { "" } else { "s" }; +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut applicability = Applicability::MachineApplicable; let sugg = snippet_with_applicability(cx, into_iter_recv.span.source_callsite(), "", &mut applicability).into_owned(); span_lint_and_then(cx, USELESS_CONVERSION, e.span, "explicit call to `.into_iter()` in function argument accepting `IntoIterator`", |diag| { diag.span_suggestion( e.span, +<<<<<<< HEAD +<<<<<<< HEAD + format!("consider removing the `.into_iter()`{plural}"), +======= +<<<<<<< HEAD +<<<<<<< HEAD + format!("consider removing the `.into_iter()`{plural}"), +======= + "consider removing `.into_iter()`", +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + format!("consider removing the `.into_iter()`{plural}"), +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= format!("consider removing the `.into_iter()`{plural}"), +>>>>>>> 615b25c20 (Rebase attempt number 2) sugg, applicability, ); diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 76654bfe5360..8abdde4f1e2b 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -35,7 +35,27 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[ "CamelCase", ]; const DEFAULT_DISALLOWED_NAMES: &[&str] = &["foo", "baz", "quux"]; +<<<<<<< HEAD +<<<<<<< HEAD const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "w", "n"]; +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "w", "n"]; +======= +const DEFAULT_ALLOWED_IDENTS: &[char] = &['i', 'j', 'x', 'y', 'z', 'n']; +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +======= +const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "n"]; +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "w", "n"]; +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +const DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS: &[&str] = &["i", "j", "x", "y", "z", "w", "n"]; +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Holds information used by `MISSING_ENFORCED_IMPORT_RENAMES` lint. #[derive(Clone, Debug, Deserialize)] @@ -294,7 +314,31 @@ define_Conf! { /// /// Suppress lints whenever the suggested change would cause breakage for other crates. (avoid_breaking_exported_api: bool = true), +<<<<<<< HEAD +<<<<<<< HEAD + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD. +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD. +======= + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS. +>>>>>>> 33b6d0d20 (rename MSRV alias, add MSRV to lint doc) +======= + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS. +>>>>>>> 211278bc8 (updated list of lints that use msrv) +======= + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS. +>>>>>>> b1acbde61 (Add msrv check and make test pass) +======= /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD. +>>>>>>> cb5d7e344 (address comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Lint: MANUAL_SPLIT_ONCE, MANUAL_STR_REPEAT, CLONED_INSTEAD_OF_COPIED, REDUNDANT_FIELD_NAMES, OPTION_MAP_UNWRAP_OR, REDUNDANT_STATIC_LIFETIMES, FILTER_MAP_NEXT, CHECKED_CONVERSIONS, MANUAL_RANGE_CONTAINS, USE_SELF, MEM_REPLACE_WITH_DEFAULT, MANUAL_NON_EXHAUSTIVE, OPTION_AS_REF_DEREF, MAP_UNWRAP_OR, MATCH_LIKE_MATCHES_MACRO, MANUAL_STRIP, MISSING_CONST_FOR_FN, UNNESTED_OR_PATTERNS, FROM_OVER_INTO, PTR_AS_PTR, IF_THEN_SOME_ELSE_NONE, APPROX_CONSTANT, DEPRECATED_CFG_ATTR, INDEX_REFUTABLE_SLICE, MAP_CLONE, BORROW_AS_PTR, MANUAL_BITS, ERR_EXPECT, CAST_ABS_TO_UNSIGNED, UNINLINED_FORMAT_ARGS, MANUAL_CLAMP, MANUAL_LET_ELSE, UNCHECKED_DURATION_SUBTRACTION, COLLAPSIBLE_STR_REPLACE, SEEK_FROM_CURRENT, SEEK_REWIND, UNNECESSARY_LAZY_EVALUATIONS, TRANSMUTE_PTR_TO_REF, ALMOST_COMPLETE_RANGE, NEEDLESS_BORROW, DERIVABLE_IMPLS, MANUAL_IS_ASCII_CHECK, MANUAL_REM_EUCLID, MANUAL_RETAIN, TYPE_REPETITION_IN_BOUNDS, TUPLE_ARRAY_CONVERSIONS, MANUAL_TRY_FOLD. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// The minimum rust version that the project supports (msrv: Option = None), @@ -307,10 +351,48 @@ define_Conf! { /// /// The maximum cognitive complexity a function can have (cognitive_complexity_threshold: u64 = 25), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Lint: EXCESSIVE_NESTING. /// /// The maximum amount of nesting a block can reside in (excessive_nesting_threshold: u64 = 0), +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + /// Lint: EXCESSIVE_WIDTH. + /// + /// The maximum width a statement can have + (excessive_width_threshold: u64 = 100), + /// Lint: EXCESSIVE_WIDTH. + /// + /// Whether to ignore the line's indentation + (excessive_width_ignore_indentation: bool = true), + /// Lint: EXCESSIVE_INDENTATION. + /// + /// The maximum indentation a statement can have + (excessive_indentation_threshold: u64 = 10), +>>>>>>> 97c10075e (add the `excessive_*` style lints) +======= + /// Lint: EXCESSIVE_NESTING. + /// + /// The maximum amount of nesting a block can reside in +<<<<<<< HEAD + (excessive_nesting_threshold: u64 = 10), +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + (excessive_nesting_threshold: u64 = 0), +>>>>>>> 725399a17 (move to `complexity` but don't lint by default) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// DEPRECATED LINT: CYCLOMATIC_COMPLEXITY. /// /// Use the Cognitive Complexity lint instead. @@ -520,29 +602,130 @@ define_Conf! { /// /// The maximum byte size a `Future` can have, before it triggers the `clippy::large_futures` lint (future_size_threshold: u64 = 16 * 1024), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Lint: UNNECESSARY_BOX_RETURNS. /// /// The byte size a `T` in `Box` can have, below which it triggers the `clippy::unnecessary_box` lint (unnecessary_box_size: u64 = 128), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + /// Lint: SEMICOLON_INSIDE_BLOCK. + /// + /// Whether to lint only if it's multiline. + (semicolon_inside_block_if_multiline: bool = false), + /// Lint: SEMICOLON_OUTSIDE_BLOCK. + /// + /// Whether to lint only if it's singleline. + (semicolon_outside_block_if_singleline: bool = false), +>>>>>>> a3aeec4f7 (config instead of new lint and don't panic) +======= +>>>>>>> 41f6d88be (make cargo test pass) +======= +======= +>>>>>>> b303e2053 (allow disabling module inception on private modules) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Lint: MODULE_INCEPTION. /// /// Whether to allow module inception if it's not public. (allow_private_module_inception: bool = false), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + /// Lint: MIN_IDENT_CHARS. + /// + /// Allowed names below the minimum allowed characters. The value `".."` can be used as part of + /// the list to indicate, that the configured values should be appended to the default + /// configuration of Clippy. By default, any configuration will replace the default value. +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= /// Lint: MIN_IDENT_CHARS. /// +<<<<<<< HEAD + /// Allowed names below the minimum allowed characters. +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= /// Allowed names below the minimum allowed characters. The value `".."` can be used as part of /// the list to indicate, that the configured values should be appended to the default /// configuration of Clippy. By default, any configuration will replace the default value. +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) (allowed_idents_below_min_chars: rustc_data_structures::fx::FxHashSet = super::DEFAULT_ALLOWED_IDENTS_BELOW_MIN_CHARS.iter().map(ToString::to_string).collect()), /// Lint: MIN_IDENT_CHARS. /// /// Minimum chars an ident can have, anything below or equal to this will be linted. (min_ident_chars_threshold: u64 = 1), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// Lint: UNDOCUMENTED_UNSAFE_BLOCKS. /// /// Whether to accept a safety comment to be placed above the statement containing the `unsafe` block (accept_comment_above_statement: bool = false), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + /// Lint: UNDOCUMENTED_UNSAFE_BLOCKS. + /// + /// Whether to accept a safety comment to be placed above the attributes for the `unsafe` block + (accept_comment_above_attributes: bool = false), + /// Lint: UNNECESSARY_RAW_STRING_HASHES. + /// + /// Whether to allow `r#""#` when `r""` can be used + (allow_one_hash_in_raw_strings: bool = false), +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +>>>>>>> b303e2053 (allow disabling module inception on private modules) +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + /// Lint: UNDOCUMENTED_UNSAFE_BLOCKS. + /// + /// Whether to accept a safety comment to be placed above the statement containing the `unsafe` block + (accept_comment_above_statement: bool = false), +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= + /// Lint: UNDOCUMENTED_UNSAFE_BLOCKS. + /// + /// Whether to accept a safety comment to be placed above the attributes for the `unsafe` block + (accept_comment_above_attributes: bool = false), +>>>>>>> cc2e49f69 (allow safety comment above attributes) +======= /// Lint: UNDOCUMENTED_UNSAFE_BLOCKS. /// /// Whether to accept a safety comment to be placed above the attributes for the `unsafe` block @@ -550,7 +733,15 @@ define_Conf! { /// Lint: UNNECESSARY_RAW_STRING_HASHES. /// /// Whether to allow `r#""#` when `r""` can be used +<<<<<<< HEAD + (allow_one_hash_in_raw_string: bool = false), +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= (allow_one_hash_in_raw_strings: bool = false), +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } /// Search for the configuration file. diff --git a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs index 570a88a0ed2b..15712c383d26 100644 --- a/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs +++ b/clippy_lints/src/utils/internal_lints/almost_standard_lint_formulation.rs @@ -35,7 +35,23 @@ struct StandardFormulations<'a> { impl AlmostStandardFormulation { pub fn new() -> Self { let standard_formulations = vec![StandardFormulations { +<<<<<<< HEAD +<<<<<<< HEAD wrong_pattern: Regex::new("^(Check for|Detects? uses?)").unwrap(), +======= +<<<<<<< HEAD +<<<<<<< HEAD + wrong_pattern: Regex::new("^(Check for|Detects? uses?)").unwrap(), +======= + wrong_pattern: Regex::new(r"^(Check for|Detects? uses?)").unwrap(), +>>>>>>> 7ac15f900 (Add lint to check lint formulation messages) +======= + wrong_pattern: Regex::new("^(Check for|Detects? uses?)").unwrap(), +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + wrong_pattern: Regex::new("^(Check for|Detects? uses?)").unwrap(), +>>>>>>> 615b25c20 (Rebase attempt number 2) correction: "Checks for", }]; Self { standard_formulations } diff --git a/clippy_lints/src/utils/mod.rs b/clippy_lints/src/utils/mod.rs index fb08256931f6..406bf3e9408e 100644 --- a/clippy_lints/src/utils/mod.rs +++ b/clippy_lints/src/utils/mod.rs @@ -69,10 +69,31 @@ impl ClippyConfiguration { .join("\n"), ) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d5b2f1134 (Now `cargo collect-metadata` updates the `CHANGELOG.md`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[cfg(feature = "internal")] fn to_markdown_link(&self) -> String { format!("[`{}`]: {BOOK_CONFIGS_PATH}#{}", self.name, self.name) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> b7a605471 (Refresh Lint Configuration's looks) +======= +>>>>>>> d5b2f1134 (Now `cargo collect-metadata` updates the `CHANGELOG.md`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } #[cfg(feature = "internal")] diff --git a/clippy_lints/src/vec.rs b/clippy_lints/src/vec.rs index 6a96114ae769..7eda7b10d2b3 100644 --- a/clippy_lints/src/vec.rs +++ b/clippy_lints/src/vec.rs @@ -2,7 +2,22 @@ use std::ops::ControlFlow; use clippy_utils::consts::{constant, Constant}; use clippy_utils::diagnostics::span_lint_and_sugg; +<<<<<<< HEAD +<<<<<<< HEAD use clippy_utils::msrvs::{self, Msrv}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use clippy_utils::msrvs::{self, Msrv}; +======= +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= +use clippy_utils::msrvs::{self, Msrv}; +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use clippy_utils::msrvs::{self, Msrv}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use clippy_utils::source::snippet_with_applicability; use clippy_utils::ty::is_copy; use clippy_utils::visitors::for_each_local_use_after_expr; @@ -53,14 +68,50 @@ declare_clippy_lint! { impl_lint_pass!(UselessVec => [USELESS_VEC]); fn adjusts_to_slice(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { +<<<<<<< HEAD +<<<<<<< HEAD matches!(cx.typeck_results().expr_ty_adjusted(e).kind(), ty::Ref(_, ty, _) if ty.is_slice()) +======= +<<<<<<< HEAD +<<<<<<< HEAD + matches!(cx.typeck_results().expr_ty_adjusted(e).kind(), ty::Ref(_, ty, _) if ty.is_slice()) +======= + if let ty::Ref(_, ty, _) = cx.typeck_results().expr_ty_adjusted(e).kind() { + ty.is_slice() + } else { + false + } +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + matches!(cx.typeck_results().expr_ty_adjusted(e).kind(), ty::Ref(_, ty, _) if ty.is_slice()) +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + matches!(cx.typeck_results().expr_ty_adjusted(e).kind(), ty::Ref(_, ty, _) if ty.is_slice()) +>>>>>>> 615b25c20 (Rebase attempt number 2) } /// Checks if the given expression is a method call to a `Vec` method /// that also exists on slices. If this returns true, it means that /// this expression does not actually require a `Vec` and could just work with an array. fn is_allowed_vec_method(cx: &LateContext<'_>, e: &Expr<'_>) -> bool { +<<<<<<< HEAD +<<<<<<< HEAD + const ALLOWED_METHOD_NAMES: &[&str] = &["len", "as_ptr", "is_empty"]; +======= +<<<<<<< HEAD +<<<<<<< HEAD + const ALLOWED_METHOD_NAMES: &[&str] = &["len", "as_ptr", "is_empty"]; +======= + const ALLOWED_METHOD_NAMES: &[&str] = &["len", "as_ptr", "as_slice", "is_empty"]; +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + const ALLOWED_METHOD_NAMES: &[&str] = &["len", "as_ptr", "is_empty"]; +>>>>>>> 7af77f74d (don't allow `as_slice` for now) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= const ALLOWED_METHOD_NAMES: &[&str] = &["len", "as_ptr", "is_empty"]; +>>>>>>> 615b25c20 (Rebase attempt number 2) if let ExprKind::MethodCall(path, ..) = e.kind { ALLOWED_METHOD_NAMES.contains(&path.ident.name.as_str()) @@ -74,6 +125,15 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { // search for `&vec![_]` or `vec![_]` expressions where the adjusted type is `&[_]` if_chain! { if adjusts_to_slice(cx, expr); +<<<<<<< HEAD +<<<<<<< HEAD + if let Some(vec_args) = higher::VecArgs::hir(cx, expr.peel_borrows()); + then { +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Some(vec_args) = higher::VecArgs::hir(cx, expr.peel_borrows()); then { let (suggest_slice, span) = if let ExprKind::AddrOf(BorrowKind::Ref, mutability, _) = expr.kind { @@ -86,6 +146,33 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { }; self.check_vec_macro(cx, &vec_args, span, suggest_slice); +<<<<<<< HEAD +======= + if let ExprKind::AddrOf(BorrowKind::Ref, mutability, addressee) = expr.kind; + if let Some(vec_args) = higher::VecArgs::hir(cx, addressee); + then { + self.check_vec_macro(cx, &vec_args, mutability, expr.span, SuggestSlice::Yes); +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + if let Some(vec_args) = higher::VecArgs::hir(cx, expr.peel_borrows()); + then { +>>>>>>> 0567691cb (This commit resolves issue #10655) + let (suggest_slice, span) = if let ExprKind::AddrOf(BorrowKind::Ref, mutability, _) = expr.kind { + // `expr` is `&vec![_]`, so suggest `&[_]` (or `&mut[_]` resp.) + (SuggestedType::SliceRef(mutability), expr.span) + } else { + // `expr` is the `vec![_]` expansion, so suggest `[_]` + // and also use the span of the actual `vec![_]` expression + (SuggestedType::Array, expr.span.ctxt().outer_expn_data().call_site) + }; + + self.check_vec_macro(cx, &vec_args, span, suggest_slice); +<<<<<<< HEAD +======= +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } @@ -96,7 +183,23 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { // for now ignore locals with type annotations. // this is to avoid compile errors when doing the suggestion here: let _: Vec<_> = vec![..]; && local.ty.is_none() +<<<<<<< HEAD +<<<<<<< HEAD + && let PatKind::Binding(_, id, ..) = local.pat.kind +======= +<<<<<<< HEAD +<<<<<<< HEAD + && let PatKind::Binding(_, id, ..) = local.pat.kind +======= + && let PatKind::Binding(BindingAnnotation(_, mutbl), id, ..) = local.pat.kind +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= && let PatKind::Binding(_, id, ..) = local.pat.kind +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && let PatKind::Binding(_, id, ..) = local.pat.kind +>>>>>>> 615b25c20 (Rebase attempt number 2) && is_copy(cx, vec_type(cx.typeck_results().expr_ty_adjusted(expr))) { let only_slice_uses = for_each_local_use_after_expr(cx, id, expr.hir_id, |expr| { @@ -116,8 +219,29 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { self.check_vec_macro( cx, &vec_args, +<<<<<<< HEAD +<<<<<<< HEAD + expr.span.ctxt().outer_expn_data().call_site, + SuggestedType::Array +======= +<<<<<<< HEAD +<<<<<<< HEAD expr.span.ctxt().outer_expn_data().call_site, SuggestedType::Array +======= + mutbl, + expr.span.ctxt().outer_expn_data().call_site, + SuggestSlice::No +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + expr.span.ctxt().outer_expn_data().call_site, + SuggestedType::Array +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + expr.span.ctxt().outer_expn_data().call_site, + SuggestedType::Array +>>>>>>> 615b25c20 (Rebase attempt number 2) ); } } @@ -130,12 +254,49 @@ impl<'tcx> LateLintPass<'tcx> for UselessVec { then { // report the error around the `vec!` not inside `:` let span = arg.span.ctxt().outer_expn_data().call_site; +<<<<<<< HEAD +<<<<<<< HEAD + self.check_vec_macro(cx, &vec_args, span, SuggestedType::Array); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + self.check_vec_macro(cx, &vec_args, span, SuggestedType::Array); +======= + self.check_vec_macro(cx, &vec_args, Mutability::Not, span, SuggestSlice::Yes); +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + self.check_vec_macro(cx, &vec_args, Mutability::Not, span, SuggestSlice::No); +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +======= self.check_vec_macro(cx, &vec_args, span, SuggestedType::Array); +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + self.check_vec_macro(cx, &vec_args, span, SuggestedType::Array); +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } extract_msrv_attr!(LateContext); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +} + +#[derive(Copy, Clone)] +enum SuggestedType { + /// Suggest using a slice `&[..]` / `&mut [..]` + SliceRef(Mutability), + /// Suggest using an array: `[..]` + Array, +======= +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } #[derive(Copy, Clone)] @@ -152,6 +313,14 @@ impl UselessVec { cx: &LateContext<'tcx>, vec_args: &higher::VecArgs<'tcx>, span: Span, +<<<<<<< HEAD +<<<<<<< HEAD + suggest_slice: SuggestedType, +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) suggest_slice: SuggestedType, ) { if span.from_expansion() { @@ -160,6 +329,34 @@ impl UselessVec { let mut applicability = Applicability::MachineApplicable; +<<<<<<< HEAD +======= + suggest_slice: SuggestSlice, +>>>>>>> 0567691cb (This commit resolves issue #10655) + ) { + if span.from_expansion() { + return; + } + + let mut applicability = Applicability::MachineApplicable; + +<<<<<<< HEAD +======= + let (borrow_prefix_mut, borrow_prefix) = match suggest_slice { + SuggestSlice::Yes => ("&mut ", "&"), + SuggestSlice::No => ("", ""), + }; + +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + suggest_slice: SuggestedType, + ) { + let mut applicability = Applicability::MachineApplicable; + +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let snippet = match *vec_args { higher::VecArgs::Repeat(elem, len) => { if let Some(Constant::Int(len_constant)) = constant(cx, cx.typeck_results(), len) { @@ -168,6 +365,16 @@ impl UselessVec { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let elem = snippet_with_applicability(cx, elem.span, "elem", &mut applicability); let len = snippet_with_applicability(cx, len.span, "len", &mut applicability); @@ -175,6 +382,32 @@ impl UselessVec { SuggestedType::SliceRef(Mutability::Mut) => format!("&mut [{elem}; {len}]"), SuggestedType::SliceRef(Mutability::Not) => format!("&[{elem}; {len}]"), SuggestedType::Array => format!("[{elem}; {len}]"), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + match mutability { + Mutability::Mut => { + format!( + "{borrow_prefix_mut}[{}; {}]", + snippet_with_applicability(cx, elem.span, "elem", &mut applicability), + snippet_with_applicability(cx, len.span, "len", &mut applicability) + ) + }, + Mutability::Not => { + format!( + "{borrow_prefix}[{}; {}]", + snippet_with_applicability(cx, elem.span, "elem", &mut applicability), + snippet_with_applicability(cx, len.span, "len", &mut applicability) + ) + }, +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } else { return; @@ -188,9 +421,45 @@ impl UselessVec { let span = args[0].span.source_callsite().to(last.span.source_callsite()); let args = snippet_with_applicability(cx, span, "..", &mut applicability); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + match suggest_slice { + SuggestedType::SliceRef(Mutability::Mut) => { + format!("&mut [{args}]") + }, + SuggestedType::SliceRef(Mutability::Not) => { + format!("&[{args}]") + }, + SuggestedType::Array => { + format!("[{args}]") + }, + } + } else { + match suggest_slice { + SuggestedType::SliceRef(Mutability::Mut) => "&mut []".to_owned(), + SuggestedType::SliceRef(Mutability::Not) => "&[]".to_owned(), + SuggestedType::Array => "[]".to_owned(), +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + match mutability { + Mutability::Mut => { + format!( + "{borrow_prefix_mut}[{}]", + snippet_with_applicability(cx, span, "..", &mut applicability) + ) +======= match suggest_slice { SuggestedType::SliceRef(Mutability::Mut) => { format!("&mut [{args}]") +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) }, SuggestedType::SliceRef(Mutability::Not) => { format!("&[{args}]") @@ -200,10 +469,20 @@ impl UselessVec { }, } } else { +<<<<<<< HEAD + match mutability { + Mutability::Mut => format!("{borrow_prefix_mut}[]"), + Mutability::Not => format!("{borrow_prefix}[]"), +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= match suggest_slice { SuggestedType::SliceRef(Mutability::Mut) => "&mut []".to_owned(), SuggestedType::SliceRef(Mutability::Not) => "&[]".to_owned(), SuggestedType::Array => "[]".to_owned(), +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } }, @@ -217,8 +496,28 @@ impl UselessVec { &format!( "you can use {} directly", match suggest_slice { +<<<<<<< HEAD +<<<<<<< HEAD + SuggestedType::SliceRef(_) => "a slice", + SuggestedType::Array => "an array", +======= +<<<<<<< HEAD +<<<<<<< HEAD + SuggestedType::SliceRef(_) => "a slice", + SuggestedType::Array => "an array", +======= + SuggestSlice::Yes => "a slice", + SuggestSlice::No => "an array", +>>>>>>> 566a365d4 (make `useless_vec` smarter) +======= + SuggestedType::SliceRef(_) => "a slice", + SuggestedType::Array => "an array", +>>>>>>> b309875fd ([`useless_vec`]: detect unnecessary `vec![_]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= SuggestedType::SliceRef(_) => "a slice", SuggestedType::Array => "an array", +>>>>>>> 615b25c20 (Rebase attempt number 2) } ), snippet, diff --git a/clippy_lints/src/visibility.rs b/clippy_lints/src/visibility.rs index 496376520019..f61955b78c0c 100644 --- a/clippy_lints/src/visibility.rs +++ b/clippy_lints/src/visibility.rs @@ -25,18 +25,68 @@ declare_clippy_lint! { /// ``` #[clippy::version = "1.72.0"] pub NEEDLESS_PUB_SELF, +<<<<<<< HEAD +<<<<<<< HEAD style, +======= +<<<<<<< HEAD +<<<<<<< HEAD + style, +======= + complexity, +>>>>>>> 8296a338d (new lints for visibility) +======= + style, +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + style, +>>>>>>> 615b25c20 (Rebase attempt number 2) "checks for usage of `pub(self)` and `pub(in self)`." } declare_clippy_lint! { /// ### What it does +<<<<<<< HEAD +<<<<<<< HEAD + /// Checks for usage of `pub()` with `in`. +======= +<<<<<<< HEAD +<<<<<<< HEAD /// Checks for usage of `pub()` with `in`. +======= + /// Checks for missing usage of the `pub(in )` shorthand. +>>>>>>> 8296a338d (new lints for visibility) +======= + /// Checks for usage of `pub()` with `in`. +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Checks for usage of `pub()` with `in`. +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// ### Why is this bad? /// Consistency. Use it or don't, just be consistent about it. /// +<<<<<<< HEAD +<<<<<<< HEAD + /// Also see the `pub_without_shorthand` lint for an alternative. + /// +======= +<<<<<<< HEAD +<<<<<<< HEAD /// Also see the `pub_without_shorthand` lint for an alternative. /// +======= +>>>>>>> 8296a338d (new lints for visibility) +======= + /// Also see the `pub_without_shorthand` lint for an alternative. + /// +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Also see the `pub_without_shorthand` lint for an alternative. + /// +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ### Example /// ```rust,ignore /// pub(super) type OptBox = Option>; @@ -48,11 +98,39 @@ declare_clippy_lint! { #[clippy::version = "1.72.0"] pub PUB_WITH_SHORTHAND, restriction, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) "disallows usage of `pub()`, without `in`" } declare_clippy_lint! { /// ### What it does /// Checks for usage of `pub()` without `in`. +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + "disallows usage of the `pub()`, suggesting use of the `in` shorthand" +} +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of the `pub(in )` shorthand. +>>>>>>> 8296a338d (new lints for visibility) +======= + "disallows usage of `pub()`, without `in`" +} +declare_clippy_lint! { + /// ### What it does + /// Checks for usage of `pub()` without `in`. +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// /// Note: As you cannot write a module's path in `pub()`, this will only trigger on /// `pub(super)` and the like. @@ -60,8 +138,26 @@ declare_clippy_lint! { /// ### Why is this bad? /// Consistency. Use it or don't, just be consistent about it. /// +<<<<<<< HEAD +<<<<<<< HEAD + /// Also see the `pub_with_shorthand` lint for an alternative. + /// +======= +<<<<<<< HEAD +<<<<<<< HEAD /// Also see the `pub_with_shorthand` lint for an alternative. /// +======= +>>>>>>> 8296a338d (new lints for visibility) +======= + /// Also see the `pub_with_shorthand` lint for an alternative. + /// +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + /// Also see the `pub_with_shorthand` lint for an alternative. + /// +>>>>>>> 615b25c20 (Rebase attempt number 2) /// ### Example /// ```rust,ignore /// pub(in super) type OptBox = Option>; @@ -73,7 +169,23 @@ declare_clippy_lint! { #[clippy::version = "1.72.0"] pub PUB_WITHOUT_SHORTHAND, restriction, +<<<<<<< HEAD +<<<<<<< HEAD + "disallows usage of `pub(in )` with `in`" +======= +<<<<<<< HEAD +<<<<<<< HEAD + "disallows usage of `pub(in )` with `in`" +======= + "disallows usage of the `pub(in )` shorthand wherever possible" +>>>>>>> 8296a338d (new lints for visibility) +======= + "disallows usage of `pub(in )` with `in`" +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= "disallows usage of `pub(in )` with `in`" +>>>>>>> 615b25c20 (Rebase attempt number 2) } declare_lint_pass!(Visibility => [NEEDLESS_PUB_SELF, PUB_WITH_SHORTHAND, PUB_WITHOUT_SHORTHAND]); diff --git a/clippy_utils/src/check_proc_macro.rs b/clippy_utils/src/check_proc_macro.rs index 89f8a65c5ae0..4c45399e04d9 100644 --- a/clippy_utils/src/check_proc_macro.rs +++ b/clippy_utils/src/check_proc_macro.rs @@ -286,6 +286,14 @@ fn fn_kind_pat(tcx: TyCtxt<'_>, kind: &FnKind<'_>, body: &Body<'_>, hir_id: HirI fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) { match attr.kind { AttrKind::Normal(..) => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut pat = if matches!(attr.style, AttrStyle::Outer) { (Pat::Str("#["), Pat::Str("]")) } else { @@ -301,6 +309,35 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) { } pat +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + if matches!(attr.style, AttrStyle::Outer) { +======= + let mut pat = if matches!(attr.style, AttrStyle::Outer) { +>>>>>>> 497f37793 (Fix `attr_search_pat` for `#[cfg_attr]`) + (Pat::Str("#["), Pat::Str("]")) + } else { + (Pat::Str("#!["), Pat::Str("]")) + }; + + if let Some(ident) = attr.ident() && let Pat::Str(old_pat) = pat.0 { + // TODO: I feel like it's likely we can use `Cow` instead but this will require quite a bit of + // refactoring + // NOTE: This will likely have false positives, like `allow = 1` + pat.0 = Pat::OwnedMultiStr(vec![ident.to_string(), old_pat.to_owned()]); + pat.1 = Pat::Str(""); + } +<<<<<<< HEAD +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= + + pat +>>>>>>> 497f37793 (Fix `attr_search_pat` for `#[cfg_attr]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }, AttrKind::DocComment(_kind @ CommentKind::Line, ..) => { if matches!(attr.style, AttrStyle::Outer) { @@ -319,6 +356,32 @@ fn attr_search_pat(attr: &Attribute) -> (Pat, Pat) { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +// TODO: Waiting on `ty_search_pat`. +// fn where_pred_search_pat(where_pred: &WherePredicate<'_>) -> (Pat, Pat) { +// match where_pred { +// WherePredicate::BoundPredicate(bound) => { +// todo!(); +// }, +// WherePredicate::RegionPredicate(region) => { +// +// }, +// WherePredicate::EqPredicate(..) => unimplemented!(), +// } +// } + +>>>>>>> e97f190a9 (`ty_search_pat`) +======= +>>>>>>> 4191de330 (Update check_proc_macro.rs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) { match ty.kind { TyKind::Slice(..) | TyKind::Array(..) => (Pat::Str("["), Pat::Str("]")), @@ -338,17 +401,55 @@ fn ty_search_pat(ty: &Ty<'_>) -> (Pat, Pat) { TyKind::Never => (Pat::Str("!"), Pat::Str("")), TyKind::Tup(..) => (Pat::Str("("), Pat::Str(")")), TyKind::OpaqueDef(..) => (Pat::Str("impl"), Pat::Str("")), +<<<<<<< HEAD +<<<<<<< HEAD TyKind::Path(qpath) => qpath_search_pat(&qpath), // NOTE: This is missing `TraitObject`. It will always return true then. +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + TyKind::Path(qpath) => qpath_search_pat(&qpath), + // NOTE: This is missing `TraitObject`. It will always return true then. +<<<<<<< HEAD +>>>>>>> 885a18207 (Fix typos) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => (Pat::Str(""), Pat::Str("")), } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn ident_search_pat(ident: Ident) -> (Pat, Pat) { (Pat::OwnedStr(ident.name.as_str().to_owned()), Pat::Str("")) } pub trait WithSearchPat<'cx> { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +======= +>>>>>>> e97f190a9 (`ty_search_pat`) +pub trait WithSearchPat { +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) type Context: LintContext; fn search_pat(&self, cx: &Self::Context) -> (Pat, Pat); fn span(&self) -> Span; @@ -388,6 +489,14 @@ impl<'cx> WithSearchPat<'cx> for (&FnKind<'cx>, &Body<'cx>, HirId, Span) { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // `Attribute` does not have the `hir` associated lifetime, so we cannot use the macro impl<'cx> WithSearchPat<'cx> for &'cx Attribute { type Context = LateContext<'cx>; @@ -411,6 +520,34 @@ impl<'cx> WithSearchPat<'cx> for Ident { fn span(&self) -> Span { self.span +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +impl<'cx> WithSearchPat for (&Attribute, &LateContext<'cx>) { +======= +// `Attribute` does not have the `hir` associated lifetime, so we cannot use the macro +impl<'cx> WithSearchPat for &'cx Attribute { +>>>>>>> 05bfcbd91 (remove tuple) + type Context = LateContext<'cx>; + + fn search_pat(&self, _cx: &Self::Context) -> (Pat, Pat) { + attr_search_pat(self) + } + + fn span(&self) -> Span { +<<<<<<< HEAD + self.0.span +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= + self.span +>>>>>>> 05bfcbd91 (remove tuple) +======= +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } diff --git a/clippy_utils/src/consts.rs b/clippy_utils/src/consts.rs index 419b139f4002..7bf7ecbd3eb8 100644 --- a/clippy_utils/src/consts.rs +++ b/clippy_utils/src/consts.rs @@ -1,11 +1,41 @@ #![allow(clippy::float_cmp)] +<<<<<<< HEAD +<<<<<<< HEAD use crate::source::{get_source_text, walk_span_to_context}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use crate::source::{get_source_text, walk_span_to_context}; +======= +use crate::source::{span_source_range, walk_span_to_context}; +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= +use crate::source::{get_source_text, walk_span_to_context}; +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use crate::source::{get_source_text, walk_span_to_context}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use crate::{clip, is_direct_expn_of, sext, unsext}; use if_chain::if_chain; use rustc_ast::ast::{self, LitFloatType, LitKind}; use rustc_data_structures::sync::Lrc; use rustc_hir::def::{DefKind, Res}; +<<<<<<< HEAD +<<<<<<< HEAD +use rustc_hir::{BinOp, BinOpKind, Block, ConstBlock, Expr, ExprKind, HirId, Item, ItemKind, Node, QPath, UnOp}; +use rustc_lexer::tokenize; +use rustc_lint::LateContext; +use rustc_middle::mir::interpret::Scalar; +use rustc_middle::ty::{self, EarlyBinder, FloatTy, List, ScalarInt, SubstsRef, Ty, TyCtxt}; +use rustc_middle::{bug, mir, span_bug}; +use rustc_span::symbol::{Ident, Symbol}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_hir::{BinOp, BinOpKind, Block, ConstBlock, Expr, ExprKind, HirId, Item, ItemKind, Node, QPath, UnOp}; use rustc_lexer::tokenize; use rustc_lint::LateContext; @@ -13,6 +43,16 @@ use rustc_middle::mir::interpret::Scalar; use rustc_middle::ty::{self, EarlyBinder, FloatTy, List, ScalarInt, SubstsRef, Ty, TyCtxt}; use rustc_middle::{bug, mir, span_bug}; use rustc_span::symbol::{Ident, Symbol}; +<<<<<<< HEAD +======= +use rustc_span::symbol::Symbol; +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= +use rustc_span::symbol::{Ident, Symbol}; +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_span::SyntaxContext; use std::cmp::Ordering::{self, Equal}; use std::hash::{Hash, Hasher}; @@ -250,7 +290,23 @@ pub fn constant<'tcx>( lcx: &LateContext<'tcx>, typeck_results: &ty::TypeckResults<'tcx>, e: &Expr<'_>, +<<<<<<< HEAD +<<<<<<< HEAD +) -> Option> { +======= +<<<<<<< HEAD +<<<<<<< HEAD +) -> Option> { +======= +) -> Option { +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= ) -> Option> { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +) -> Option> { +>>>>>>> 615b25c20 (Rebase attempt number 2) ConstEvalLateContext::new(lcx, typeck_results).expr(e) } @@ -259,7 +315,23 @@ pub fn constant_with_source<'tcx>( lcx: &LateContext<'tcx>, typeck_results: &ty::TypeckResults<'tcx>, e: &Expr<'_>, +<<<<<<< HEAD +<<<<<<< HEAD +) -> Option<(Constant<'tcx>, ConstantSource)> { +======= +<<<<<<< HEAD +<<<<<<< HEAD ) -> Option<(Constant<'tcx>, ConstantSource)> { +======= +) -> Option<(Constant, ConstantSource)> { +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= +) -> Option<(Constant<'tcx>, ConstantSource)> { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +) -> Option<(Constant<'tcx>, ConstantSource)> { +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut ctxt = ConstEvalLateContext::new(lcx, typeck_results); let res = ctxt.expr(e); res.map(|x| (x, ctxt.source)) @@ -270,7 +342,23 @@ pub fn constant_simple<'tcx>( lcx: &LateContext<'tcx>, typeck_results: &ty::TypeckResults<'tcx>, e: &Expr<'_>, +<<<<<<< HEAD +<<<<<<< HEAD +) -> Option> { +======= +<<<<<<< HEAD +<<<<<<< HEAD +) -> Option> { +======= +) -> Option { +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= ) -> Option> { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +) -> Option> { +>>>>>>> 615b25c20 (Rebase attempt number 2) constant_with_source(lcx, typeck_results, e).and_then(|(c, s)| s.is_local().then_some(c)) } @@ -343,6 +431,16 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { pub fn expr(&mut self, e: &Expr<'_>) -> Option> { match e.kind { ExprKind::ConstBlock(ConstBlock { body, .. }) => self.expr(self.lcx.tcx.hir().body(body).value), +<<<<<<< HEAD +======= +<<<<<<< HEAD + ExprKind::ConstBlock(ConstBlock { body, .. }) => self.expr(self.lcx.tcx.hir().body(body).value), +======= + ExprKind::ConstBlock(AnonConst { body, .. }) => self.expr(self.lcx.tcx.hir().body(body).value), +>>>>>>> 6a1084c26 (Check if `if` conditions always evaluate to true in `never_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ExprKind::DropTemps(e) => self.expr(e), ExprKind::Path(ref qpath) => self.fetch_path(qpath, e.hir_id, self.typeck_results.expr_ty(e)), ExprKind::Block(block, _) => self.block(block), @@ -396,7 +494,23 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { }, ExprKind::Index(arr, index) => self.index(arr, index), ExprKind::AddrOf(_, _, inner) => self.expr(inner).map(|r| Constant::Ref(Box::new(r))), +<<<<<<< HEAD +<<<<<<< HEAD + ExprKind::Field(local_expr, ref field) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + ExprKind::Field(local_expr, ref field) => { +======= + ExprKind::Field(ref local_expr, ref field) => { +>>>>>>> 0e1caa765 (Fix #10792) +======= + ExprKind::Field(local_expr, ref field) => { +>>>>>>> dbe405723 (Dogfood) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= ExprKind::Field(local_expr, ref field) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) let result = self.expr(local_expr); if let Some(Constant::Adt(constant)) = &self.expr(local_expr) && let ty::Adt(adt_def, _) = constant.ty().kind() @@ -483,7 +597,23 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { .const_eval_resolve(self.param_env, mir::UnevaluatedConst::new(def_id, substs), None) .ok() .map(|val| rustc_middle::mir::ConstantKind::from_value(val, ty))?; +<<<<<<< HEAD +<<<<<<< HEAD let result = miri_to_const(self.lcx, result)?; +======= +<<<<<<< HEAD +<<<<<<< HEAD + let result = miri_to_const(self.lcx, result)?; +======= + let result = miri_to_const(self.lcx.tcx, result)?; +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= + let result = miri_to_const(self.lcx, result)?; +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let result = miri_to_const(self.lcx, result)?; +>>>>>>> 615b25c20 (Rebase attempt number 2) self.source = ConstantSource::Constant; Some(result) }, @@ -517,7 +647,23 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { } /// A block can only yield a constant if it only has one constant expression. +<<<<<<< HEAD +<<<<<<< HEAD + fn block(&mut self, block: &Block<'_>) -> Option> { +======= +<<<<<<< HEAD +<<<<<<< HEAD + fn block(&mut self, block: &Block<'_>) -> Option> { +======= + fn block(&mut self, block: &Block<'_>) -> Option { +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= fn block(&mut self, block: &Block<'_>) -> Option> { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + fn block(&mut self, block: &Block<'_>) -> Option> { +>>>>>>> 615b25c20 (Rebase attempt number 2) if block.stmts.is_empty() && let Some(expr) = block.expr { @@ -527,7 +673,23 @@ impl<'a, 'tcx> ConstEvalLateContext<'a, 'tcx> { if let Some(expr_span) = walk_span_to_context(expr.span, span.ctxt) && let expr_lo = expr_span.lo() && expr_lo >= span.lo +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(src) = get_source_text(self.lcx, span.lo..expr_lo) +======= +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(src) = get_source_text(self.lcx, span.lo..expr_lo) +======= + && let Some(src) = span_source_range(self.lcx, span.lo..expr_lo) +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +======= && let Some(src) = get_source_text(self.lcx, span.lo..expr_lo) +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && let Some(src) = get_source_text(self.lcx, span.lo..expr_lo) +>>>>>>> 615b25c20 (Rebase attempt number 2) && let Some(src) = src.as_str() { use rustc_lexer::TokenKind::{Whitespace, LineComment, BlockComment, Semi, OpenBrace}; @@ -688,6 +850,16 @@ pub fn miri_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::ConstantKind<'t ty::Adt(adt_def, _) if adt_def.is_struct() => Some(Constant::Adt(result)), ty::Array(sub_type, len) => match sub_type.kind() { ty::Float(FloatTy::F32) => match len.try_to_target_usize(lcx.tcx) { +<<<<<<< HEAD +======= +<<<<<<< HEAD + ty::Float(FloatTy::F32) => match len.try_to_target_usize(lcx.tcx) { +======= + ty::Float(FloatTy::F32) => match len.kind().try_to_target_usize(lcx.tcx) { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Some(len) => alloc .inner() .inspect_with_uninit_and_ptr_outside_interpreter(0..(4 * usize::try_from(len).unwrap())) @@ -699,6 +871,16 @@ pub fn miri_to_const<'tcx>(lcx: &LateContext<'tcx>, result: mir::ConstantKind<'t _ => None, }, ty::Float(FloatTy::F64) => match len.try_to_target_usize(lcx.tcx) { +<<<<<<< HEAD +======= +<<<<<<< HEAD + ty::Float(FloatTy::F64) => match len.try_to_target_usize(lcx.tcx) { +======= + ty::Float(FloatTy::F64) => match len.kind().try_to_target_usize(lcx.tcx) { +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Some(len) => alloc .inner() .inspect_with_uninit_and_ptr_outside_interpreter(0..(8 * usize::try_from(len).unwrap())) @@ -723,6 +905,13 @@ fn field_of_struct<'tcx>( result: mir::ConstantKind<'tcx>, field: &Ident, ) -> Option> { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let mir::ConstantKind::Val(result, ty) = result && let Some(dc) = lcx.tcx.try_destructure_mir_constant_for_diagnostics((result, ty)) && let Some(dc_variant) = dc.variant @@ -731,6 +920,21 @@ fn field_of_struct<'tcx>( && let Some(&(val, ty)) = dc.fields.get(field_idx) { Some(mir::ConstantKind::Val(val, ty)) +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let dc = lcx.tcx.destructure_mir_constant(lcx.param_env, result); + if let Some(dc_variant) = dc.variant + && let Some(variant) = adt_def.variants().get(dc_variant) + && let Some(field_idx) = variant.fields.iter().position(|el| el.name == field.name) + && let Some(dc_field) = dc.fields.get(field_idx) + { + Some(*dc_field) +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } else { None diff --git a/clippy_utils/src/eager_or_lazy.rs b/clippy_utils/src/eager_or_lazy.rs index 29b73ab4cd51..66f079bf2fcd 100644 --- a/clippy_utils/src/eager_or_lazy.rs +++ b/clippy_utils/src/eager_or_lazy.rs @@ -18,6 +18,18 @@ use rustc_hir::{Block, Expr, ExprKind, QPath, UnOp}; use rustc_lint::LateContext; use rustc_middle::ty; use rustc_middle::ty::adjustment::Adjust; +<<<<<<< HEAD +======= +<<<<<<< HEAD +use rustc_middle::ty; +use rustc_middle::ty::adjustment::Adjust; +======= +use rustc_middle::ty::adjustment::Adjust; +use rustc_middle::ty::{self, PredicateKind}; +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_span::{sym, Symbol}; use std::{cmp, ops}; diff --git a/clippy_utils/src/hir_utils.rs b/clippy_utils/src/hir_utils.rs index fb359ee3bbe0..b0210f0b495e 100644 --- a/clippy_utils/src/hir_utils.rs +++ b/clippy_utils/src/hir_utils.rs @@ -13,7 +13,23 @@ use rustc_hir::{ use rustc_lexer::{tokenize, TokenKind}; use rustc_lint::LateContext; use rustc_middle::ty::TypeckResults; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_span::{sym, BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use rustc_span::{sym, BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext}; +======= +use rustc_span::{sym, BytePos, Symbol, SyntaxContext}; +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +use rustc_span::{sym, BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext}; +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use rustc_span::{sym, BytePos, ExpnKind, MacroKind, Symbol, SyntaxContext}; +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::hash::{Hash, Hasher}; use std::ops::Range; @@ -155,8 +171,26 @@ impl HirEqInterExpr<'_, '_, '_> { if !self.eq_stmt(left, right) { return false; } +<<<<<<< HEAD +<<<<<<< HEAD + + // Try to detect any `cfg`ed statements or empty macro expansions. +======= +<<<<<<< HEAD +<<<<<<< HEAD + + // Try to detect any `cfg`ed statements or empty macro expansions. +======= +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= + + // Try to detect any `cfg`ed statements or empty macro expansions. +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // Try to detect any `cfg`ed statements or empty macro expansions. +>>>>>>> 615b25c20 (Rebase attempt number 2) let Some(lstmt_span) = walk_span_to_context(left.span, lspan.ctxt) else { return false; }; @@ -170,8 +204,27 @@ impl HirEqInterExpr<'_, '_, '_> { // Can happen when macros expand to multiple statements, or rearrange statements. // Nothing in between the statements to check in this case. continue; +<<<<<<< HEAD +<<<<<<< HEAD } if lstmt_span.lo < lstart || rstmt_span.lo < rstart { +======= +<<<<<<< HEAD +<<<<<<< HEAD + } + if lstmt_span.lo < lstart || rstmt_span.lo < rstart { +======= + } else if lstmt_span.lo < lstart || rstmt_span.lo < rstart { +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= + } + if lstmt_span.lo < lstart || rstmt_span.lo < rstart { +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + } + if lstmt_span.lo < lstart || rstmt_span.lo < rstart { +>>>>>>> 615b25c20 (Rebase attempt number 2) // Only one of the blocks had a weird macro. return false; } @@ -1122,7 +1175,22 @@ pub fn hash_expr(cx: &LateContext<'_>, e: &Expr<'_>) -> u64 { h.finish() } +<<<<<<< HEAD +<<<<<<< HEAD +#[expect(clippy::similar_names)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[expect(clippy::similar_names)] +======= +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +#[expect(clippy::similar_names)] +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= #[expect(clippy::similar_names)] +>>>>>>> 615b25c20 (Rebase attempt number 2) fn eq_span_tokens( cx: &LateContext<'_>, left: impl SpanRange, diff --git a/clippy_utils/src/lib.rs b/clippy_utils/src/lib.rs index cf33076d356d..865ded315b84 100644 --- a/clippy_utils/src/lib.rs +++ b/clippy_utils/src/lib.rs @@ -20,6 +20,17 @@ extern crate rustc_ast; extern crate rustc_ast_pretty; extern crate rustc_attr; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +extern crate rustc_const_eval; +extern crate rustc_data_structures; +======= +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate rustc_const_eval; extern crate rustc_data_structures; // The `rustc_driver` crate seems to be required in order to use the `rust_ast` crate. @@ -1509,7 +1520,23 @@ pub fn is_range_full(cx: &LateContext<'_>, expr: &Expr<'_>, container_path: Opti && let Some(min_val) = bnd_ty.numeric_min_val(cx.tcx) && let const_val = cx.tcx.valtree_to_const_val((bnd_ty, min_val.to_valtree())) && let min_const_kind = ConstantKind::from_value(const_val, bnd_ty) +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(min_const) = miri_to_const(cx, min_const_kind) +======= +<<<<<<< HEAD +<<<<<<< HEAD && let Some(min_const) = miri_to_const(cx, min_const_kind) +======= + && let Some(min_const) = miri_to_const(cx.tcx, min_const_kind) +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + && let Some(min_const) = miri_to_const(cx, min_const_kind) +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && let Some(min_const) = miri_to_const(cx, min_const_kind) +>>>>>>> 615b25c20 (Rebase attempt number 2) && let Some(start_const) = constant(cx, cx.typeck_results(), start) { start_const == min_const @@ -1525,7 +1552,23 @@ pub fn is_range_full(cx: &LateContext<'_>, expr: &Expr<'_>, container_path: Opti && let Some(max_val) = bnd_ty.numeric_max_val(cx.tcx) && let const_val = cx.tcx.valtree_to_const_val((bnd_ty, max_val.to_valtree())) && let max_const_kind = ConstantKind::from_value(const_val, bnd_ty) +<<<<<<< HEAD +<<<<<<< HEAD + && let Some(max_const) = miri_to_const(cx, max_const_kind) +======= +<<<<<<< HEAD +<<<<<<< HEAD && let Some(max_const) = miri_to_const(cx, max_const_kind) +======= + && let Some(max_const) = miri_to_const(cx.tcx, max_const_kind) +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + && let Some(max_const) = miri_to_const(cx, max_const_kind) +>>>>>>> 0e1caa765 (Fix #10792) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + && let Some(max_const) = miri_to_const(cx, max_const_kind) +>>>>>>> 615b25c20 (Rebase attempt number 2) && let Some(end_const) = constant(cx, cx.typeck_results(), end) { end_const == max_const @@ -2163,7 +2206,31 @@ pub fn fn_has_unsatisfiable_preds(cx: &LateContext<'_>, did: DefId) -> bool { .predicates .iter() .filter_map(|(p, _)| if p.is_global() { Some(*p) } else { None }); +<<<<<<< HEAD +<<<<<<< HEAD + traits::impossible_predicates(cx.tcx, traits::elaborate(cx.tcx, predicates).collect::>()) +======= +<<<<<<< HEAD + traits::impossible_predicates( + cx.tcx, +<<<<<<< HEAD +<<<<<<< HEAD + traits::elaborate_predicates(cx.tcx, predicates).collect::>(), +======= + traits::elaborate(cx.tcx, predicates) + .collect::>(), +>>>>>>> 0963a66ab (Make elaborator generic) +======= + traits::elaborate(cx.tcx, predicates).collect::>(), +>>>>>>> 6b95029f1 (Merge commit '83e42a2337dadac915c956d125f1d69132f36425' into clippyup) + ) +======= + traits::impossible_predicates(cx.tcx, traits::elaborate(cx.tcx, predicates).collect::>()) +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= traits::impossible_predicates(cx.tcx, traits::elaborate(cx.tcx, predicates).collect::>()) +>>>>>>> 615b25c20 (Rebase attempt number 2) } /// Returns the `DefId` of the callee if the given expression is a function or method call. diff --git a/clippy_utils/src/msrvs.rs b/clippy_utils/src/msrvs.rs index 3637476c4087..6d59810f58c2 100644 --- a/clippy_utils/src/msrvs.rs +++ b/clippy_utils/src/msrvs.rs @@ -19,8 +19,29 @@ macro_rules! msrv_aliases { // names may refer to stabilized feature flags or library items msrv_aliases! { +<<<<<<< HEAD +<<<<<<< HEAD 1,71,0 { TUPLE_ARRAY_CONVERSIONS } 1,70,0 { OPTION_IS_SOME_AND } +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) + 1,71,0 { TUPLE_ARRAY_CONVERSIONS } + 1,70,0 { OPTION_IS_SOME_AND } +======= + 1,70,0 { OPT_IS_SOME_AND } +>>>>>>> c60222dc1 (changed the msrv to 1.70 to suggest `is_some_and`) +======= + 1,70,0 { OPTION_IS_SOME_AND } +>>>>>>> a693cbc1b (changed msrv name for consistency & changed nested if for style) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + 1,71,0 { TUPLE_ARRAY_CONVERSIONS } + 1,70,0 { OPTION_IS_SOME_AND } +>>>>>>> 615b25c20 (Rebase attempt number 2) 1,68,0 { PATH_MAIN_SEPARATOR_STR } 1,65,0 { LET_ELSE, POINTER_CAST_CONSTNESS } 1,62,0 { BOOL_THEN_SOME, DEFAULT_ENUM_ATTRIBUTE } @@ -50,7 +71,23 @@ msrv_aliases! { 1,18,0 { HASH_MAP_RETAIN, HASH_SET_RETAIN } 1,17,0 { FIELD_INIT_SHORTHAND, STATIC_IN_CONST, EXPECT_ERR } 1,16,0 { STR_REPEAT } +<<<<<<< HEAD +<<<<<<< HEAD + 1,15,0 { MAYBE_BOUND_IN_WHERE } +======= +<<<<<<< HEAD +<<<<<<< HEAD + 1,15,0 { MAYBE_BOUND_IN_WHERE } +======= + 1,15,0 { COMBINED_MAYBE_BOUND } +>>>>>>> 87c28b946 ([`type_repetition_in_bounds`]: respect msrv for combining maybe bounds) +======= + 1,15,0 { MAYBE_BOUND_IN_WHERE } +>>>>>>> 33b6d0d20 (rename MSRV alias, add MSRV to lint doc) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= 1,15,0 { MAYBE_BOUND_IN_WHERE } +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn parse_msrv(msrv: &str, sess: Option<&Session>, span: Option) -> Option { diff --git a/clippy_utils/src/qualify_min_const_fn.rs b/clippy_utils/src/qualify_min_const_fn.rs index 1c7469081a31..c03f883ab16c 100644 --- a/clippy_utils/src/qualify_min_const_fn.rs +++ b/clippy_utils/src/qualify_min_const_fn.rs @@ -4,7 +4,23 @@ // differ from the time of `rustc` even if the name stays the same. use crate::msrvs::Msrv; +<<<<<<< HEAD +<<<<<<< HEAD use hir::LangItem; +======= +<<<<<<< HEAD +<<<<<<< HEAD +use hir::LangItem; +======= +use hir::{Constness, LangItem}; +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= +use hir::LangItem; +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +use hir::LangItem; +>>>>>>> 615b25c20 (Rebase attempt number 2) use rustc_const_eval::transform::check_consts::ConstCx; use rustc_hir as hir; use rustc_hir::def_id::DefId; @@ -14,6 +30,8 @@ use rustc_middle::mir::{ Body, CastKind, NonDivergingIntrinsic, NullOp, Operand, Place, ProjectionElem, Rvalue, Statement, StatementKind, Terminator, TerminatorKind, }; +<<<<<<< HEAD +<<<<<<< HEAD use rustc_middle::traits::{ImplSource, ObligationCause}; use rustc_middle::ty::adjustment::PointerCoercion; use rustc_middle::ty::subst::GenericArgKind; @@ -22,6 +40,29 @@ use rustc_semver::RustcVersion; use rustc_span::symbol::sym; use rustc_span::Span; use rustc_trait_selection::traits::{ObligationCtxt, SelectionContext}; +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +use rustc_middle::traits::{ImplSource, ObligationCause}; +use rustc_middle::ty::adjustment::PointerCoercion; +use rustc_middle::ty::subst::GenericArgKind; +use rustc_middle::ty::{self, BoundConstness, TraitRef, Ty, TyCtxt}; +use rustc_semver::RustcVersion; +use rustc_span::symbol::sym; +use rustc_span::Span; +use rustc_trait_selection::traits::{ObligationCtxt, SelectionContext}; +<<<<<<< HEAD +======= +use rustc_trait_selection::traits::SelectionContext; +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= +use rustc_trait_selection::traits::{ObligationCtxt, SelectionContext}; +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::borrow::Cow; type McfResult = Result<(), (Span, Cow<'static, str>)>; @@ -125,9 +166,19 @@ fn check_rvalue<'tcx>( ) => check_operand(tcx, operand, span, body), Rvalue::Cast( CastKind::PointerCoercion( +<<<<<<< HEAD +<<<<<<< HEAD + PointerCoercion::UnsafeFnPointer + | PointerCoercion::ClosureFnPointer(_) + | PointerCoercion::ReifyFnPointer, +======= + PointerCoercion::UnsafeFnPointer | PointerCoercion::ClosureFnPointer(_) | PointerCoercion::ReifyFnPointer, +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= PointerCoercion::UnsafeFnPointer | PointerCoercion::ClosureFnPointer(_) | PointerCoercion::ReifyFnPointer, +>>>>>>> 615b25c20 (Rebase attempt number 2) ), _, _, @@ -236,6 +287,16 @@ fn check_statement<'tcx>( fn check_operand<'tcx>(tcx: TyCtxt<'tcx>, operand: &Operand<'tcx>, span: Span, body: &Body<'tcx>) -> McfResult { match operand { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 9bc5a146f (remove `in_move`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Operand::Move(place) => { if !place.projection.as_ref().is_empty() && !is_ty_const_destruct(tcx, place.ty(&body.local_decls, tcx).ty, body) @@ -249,6 +310,19 @@ fn check_operand<'tcx>(tcx: TyCtxt<'tcx>, operand: &Operand<'tcx>, span: Span, b check_place(tcx, *place, span, body) }, Operand::Copy(place) => check_place(tcx, *place, span, body), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Operand::Move(place) => check_place(tcx, *place, span, body, true), + Operand::Copy(place) => check_place(tcx, *place, span, body, false), +>>>>>>> 5692677b3 (cleanup spaghetti code) +======= +>>>>>>> 9bc5a146f (remove `in_move`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Operand::Constant(c) => match c.check_static_ptr(tcx) { Some(_) => Err((span, "cannot access `static` items in const fn".into())), None => Ok(()), @@ -257,10 +331,58 @@ fn check_operand<'tcx>(tcx: TyCtxt<'tcx>, operand: &Operand<'tcx>, span: Span, b } fn check_place<'tcx>(tcx: TyCtxt<'tcx>, place: Place<'tcx>, span: Span, body: &Body<'tcx>) -> McfResult { +<<<<<<< HEAD +<<<<<<< HEAD for (base, elem) in place.as_ref().iter_projections() { +======= +<<<<<<< HEAD +<<<<<<< HEAD + for (base, elem) in place.as_ref().iter_projections() { +======= +======= +fn check_place<'tcx>(tcx: TyCtxt<'tcx>, place: Place<'tcx>, span: Span, body: &Body<'tcx>, in_move: bool) -> McfResult { +>>>>>>> 5692677b3 (cleanup spaghetti code) +======= +fn check_place<'tcx>(tcx: TyCtxt<'tcx>, place: Place<'tcx>, span: Span, body: &Body<'tcx>) -> McfResult { +>>>>>>> 9bc5a146f (remove `in_move`) + let mut cursor = place.projection.as_ref(); + + while let [ref proj_base @ .., elem] = *cursor { + cursor = proj_base; +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= + for (base, elem) in place.as_ref().iter_projections() { +>>>>>>> 66590ba41 (use PlaceRef abstractions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for (base, elem) in place.as_ref().iter_projections() { +>>>>>>> 615b25c20 (Rebase attempt number 2) match elem { ProjectionElem::Field(..) => { let base_ty = base.ty(body, tcx).ty; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + ProjectionElem::Field(_, ty) => { + if !is_ty_const_destruct(tcx, ty, body) && in_move { + return Err(( + span, + "cannot drop locals with a non constant destructor in const fn".into(), + )); + } + +======= + ProjectionElem::Field(..) => { +>>>>>>> a495fa06d (remove unnecessary checks) + let base_ty = Place::ty_from(place.local, proj_base, body, tcx).ty; +>>>>>>> 5692677b3 (cleanup spaghetti code) +======= +>>>>>>> 66590ba41 (use PlaceRef abstractions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if let Some(def) = base_ty.ty_adt_def() { // No union field accesses in `const fn` if def.is_union() { @@ -295,6 +417,14 @@ fn check_terminator<'tcx>( | TerminatorKind::Resume | TerminatorKind::Terminate | TerminatorKind::Unreachable => Ok(()), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) TerminatorKind::Drop { place, .. } => { if !is_ty_const_destruct(tcx, place.ty(&body.local_decls, tcx).ty, body) { return Err(( @@ -304,6 +434,30 @@ fn check_terminator<'tcx>( } Ok(()) }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + +======= +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) + TerminatorKind::Drop { place, .. } => { + if !is_ty_const_destruct(tcx, place.ty(&body.local_decls, tcx).ty, body) { + return Err(( + span, + "cannot drop locals with a non constant destructor in const fn".into(), + )); + } + Ok(()) + }, +<<<<<<< HEAD + +>>>>>>> e24fc9af2 (Fix `missing_const_for_fn` not checking `~const Destruct`) +======= +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) TerminatorKind::SwitchInt { discr, targets: _ } => check_operand(tcx, discr, span, body), TerminatorKind::GeneratorDrop | TerminatorKind::Yield { .. } => { Err((span, "const fn generators are unstable".into())) @@ -390,7 +544,22 @@ fn is_const_fn(tcx: TyCtxt<'_>, def_id: DefId, msrv: &Msrv) -> bool { }) } +<<<<<<< HEAD +<<<<<<< HEAD +#[expect(clippy::similar_names)] // bit too pedantic +======= +<<<<<<< HEAD +<<<<<<< HEAD #[expect(clippy::similar_names)] // bit too pedantic +======= +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= +#[expect(clippy::similar_names)] // bit too pedantic +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[expect(clippy::similar_names)] // bit too pedantic +>>>>>>> 615b25c20 (Rebase attempt number 2) fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx>) -> bool { // Avoid selecting for simple cases, such as builtin types. if ty::util::is_trivially_const_drop(ty) { @@ -400,6 +569,14 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx> let obligation = Obligation::new( tcx, ObligationCause::dummy_with_span(body.span), +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ConstCx::new(tcx, body).param_env.with_const(), TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst), ); @@ -420,4 +597,39 @@ fn is_ty_const_destruct<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, body: &Body<'tcx> let ocx = ObligationCtxt::new(&infcx); ocx.register_obligations(impl_src.nested_obligations()); ocx.select_all_or_error().is_empty() +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + ConstCx::new(tcx, body).param_env.with_constness(Constness::Const), +======= + ConstCx::new(tcx, body).param_env.with_const(), +>>>>>>> 5692677b3 (cleanup spaghetti code) + TraitRef::from_lang_item(tcx, LangItem::Destruct, body.span, [ty]).with_constness(BoundConstness::ConstIfConst), + ); + + let infcx = tcx.infer_ctxt().build(); + let mut selcx = SelectionContext::new(&infcx); +<<<<<<< HEAD + selcx.select(&obligation).is_ok() && fields_all_const_destruct +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= + let Some(impl_src) = selcx.select(&obligation).ok().flatten() else { + return false; + }; + + if !matches!( + impl_src, + ImplSource::ConstDestruct(_) | ImplSource::Param(_, ty::BoundConstness::ConstIfConst) + ) { + return false; + } + + let ocx = ObligationCtxt::new(&infcx); + ocx.register_obligations(impl_src.nested_obligations()); + ocx.select_all_or_error().is_empty() +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/clippy_utils/src/source.rs b/clippy_utils/src/source.rs index dc4ee7256817..a0e7d561e2d0 100644 --- a/clippy_utils/src/source.rs +++ b/clippy_utils/src/source.rs @@ -72,6 +72,19 @@ pub fn expr_block( let (code, from_macro) = snippet_block_with_context(cx, expr.span, outer, default, indent_relative_to, app); if !from_macro && let ExprKind::Block(block, _) = expr.kind && +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + // TODO: Is this enough UnsafeSource::UserProvided, or should CompilerGenerated be also included? +>>>>>>> e92614818 (Fix unsafe blocks) +======= +>>>>>>> 68df61ebd (remove todo) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) block.rules != BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) { format!("{code}") diff --git a/clippy_utils/src/ty.rs b/clippy_utils/src/ty.rs index 15a08370b6a5..b2cdd85a8675 100644 --- a/clippy_utils/src/ty.rs +++ b/clippy_utils/src/ty.rs @@ -1123,7 +1123,15 @@ pub fn make_normalized_projection<'tcx>( ); return None; } +<<<<<<< HEAD +<<<<<<< HEAD match tcx.try_normalize_erasing_regions(param_env, Ty::new_projection(tcx, ty.def_id, ty.substs)) { +======= + match tcx.try_normalize_erasing_regions(param_env, Ty::new_projection(tcx,ty.def_id, ty.substs)) { +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + match tcx.try_normalize_erasing_regions(param_env, Ty::new_projection(tcx, ty.def_id, ty.substs)) { +>>>>>>> 615b25c20 (Rebase attempt number 2) Ok(ty) => Some(ty), Err(e) => { debug_assert!(false, "failed to normalize type `{ty}`: {e:#?}"); @@ -1206,7 +1214,19 @@ pub fn make_normalized_projection_with_regions<'tcx>( .infer_ctxt() .build() .at(&cause, param_env) +<<<<<<< HEAD +<<<<<<< HEAD + .query_normalize(Ty::new_projection(tcx, ty.def_id, ty.substs)) +======= +<<<<<<< HEAD + .query_normalize(Ty::new_projection(tcx,ty.def_id, ty.substs)) +======= + .query_normalize(tcx.mk_projection(ty.def_id, ty.substs)) +>>>>>>> b6fa4d43d (Extend `explicit_iter_loop` to all types) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= .query_normalize(Ty::new_projection(tcx, ty.def_id, ty.substs)) +>>>>>>> 615b25c20 (Rebase attempt number 2) { Ok(ty) => Some(ty.value), Err(e) => { diff --git a/rust-toolchain b/rust-toolchain index b658101a10d8..9005efe705b7 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,3 +1,47 @@ [toolchain] +<<<<<<< HEAD +<<<<<<< HEAD channel = "nightly-2023-07-14" +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +channel = "nightly-2023-04-23" +======= +channel = "nightly-2023-05-05" +>>>>>>> 79656cc95 (Bump nightly version -> 2023-05-05) +======= +channel = "nightly-2023-05-05" +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +channel = "nightly-2023-05-20" +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= +channel = "nightly-2023-06-02" +>>>>>>> e6dc0efc0 (Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup) +======= +channel = "nightly-2023-06-29" +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +channel = "nightly-2023-05-20" +>>>>>>> 2e95a4fd4 (Bump nightly version -> 2023-05-20) +======= +channel = "nightly-2023-06-02" +>>>>>>> dfdc25834 (Bump nightly version -> 2023-06-02) +======= +channel = "nightly-2023-06-29" +>>>>>>> 30d08d35f (Bump nightly version -> 2023-06-29) +======= +channel = "nightly-2023-07-14" +>>>>>>> 753c30f34 (Bump nightly version -> 2023-07-14) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +channel = "nightly-2023-07-14" +>>>>>>> 615b25c20 (Rebase attempt number 2) components = ["cargo", "llvm-tools", "rust-src", "rust-std", "rustc", "rustc-dev", "rustfmt"] diff --git a/src/main.rs b/src/main.rs index cdc85cb33ca2..293d4ffabc41 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,23 @@ use std::env; use std::path::PathBuf; use std::process::{self, Command}; +<<<<<<< HEAD +<<<<<<< HEAD const CARGO_CLIPPY_HELP: &str = "Checks a package to catch common mistakes and improve your Rust code. +======= +<<<<<<< HEAD +<<<<<<< HEAD +const CARGO_CLIPPY_HELP: &str = "Checks a package to catch common mistakes and improve your Rust code. +======= +const CARGO_CLIPPY_HELP: &str = r"Checks a package to catch common mistakes and improve your Rust code. +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +const CARGO_CLIPPY_HELP: &str = "Checks a package to catch common mistakes and improve your Rust code. +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +const CARGO_CLIPPY_HELP: &str = "Checks a package to catch common mistakes and improve your Rust code. +>>>>>>> 615b25c20 (Rebase attempt number 2) Usage: cargo clippy [options] [--] [...] diff --git a/tests/compile-test.rs b/tests/compile-test.rs index d70c4ea34cbc..56492300a912 100644 --- a/tests/compile-test.rs +++ b/tests/compile-test.rs @@ -115,13 +115,39 @@ fn base_config(test_dir: &str) -> compiletest::Config { mode: TestMode::Yolo, stderr_filters: vec![], stdout_filters: vec![], +<<<<<<< HEAD +<<<<<<< HEAD output_conflict_handling: if var_os("BLESS").is_some() || env::args().any(|arg| arg == "--bless") { +======= +<<<<<<< HEAD +<<<<<<< HEAD + output_conflict_handling: if var_os("BLESS").is_some() || env::args().any(|arg| arg == "--bless") { +======= + output_conflict_handling: if std::env::args().any(|arg| arg == "--bless") { +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= + output_conflict_handling: if var_os("BLESS").is_some() || env::args().any(|arg| arg == "--bless") { +>>>>>>> 76de5560f (Add BLESS for compile-test and some cleanup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + output_conflict_handling: if var_os("BLESS").is_some() || env::args().any(|arg| arg == "--bless") { +>>>>>>> 615b25c20 (Rebase attempt number 2) compiletest::OutputConflictHandling::Bless } else { compiletest::OutputConflictHandling::Error("cargo test -- -- --bless".into()) }, target: None, out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into())).join("ui_test"), +<<<<<<< HEAD +======= +<<<<<<< HEAD + out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap_or("target".into())).join("ui_test"), +======= + out_dir: "target/ui_test".into(), +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) ..compiletest::Config::rustc(Path::new("tests").join(test_dir)) }; @@ -153,7 +179,23 @@ fn base_config(test_dir: &str) -> compiletest::Config { } // Normalize away slashes in windows paths. +<<<<<<< HEAD +<<<<<<< HEAD + config.stderr_filter(r"\\", "/"); +======= +<<<<<<< HEAD +<<<<<<< HEAD + config.stderr_filter(r"\\", "/"); +======= + config.stderr_filter(r#"\\"#, "/"); +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= config.stderr_filter(r"\\", "/"); +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + config.stderr_filter(r"\\", "/"); +>>>>>>> 615b25c20 (Rebase attempt number 2) //config.build_base = profile_path.join("test").join(test_dir); config.program.program = profile_path.join(if cfg!(windows) { @@ -167,7 +209,28 @@ fn base_config(test_dir: &str) -> compiletest::Config { fn test_filter() -> Box bool> { if let Ok(filters) = env::var("TESTNAME") { let filters: Vec<_> = filters.split(',').map(ToString::to_string).collect(); +<<<<<<< HEAD +<<<<<<< HEAD + Box::new(move |path| filters.iter().any(|f| path.to_string_lossy().contains(f))) +======= +<<<<<<< HEAD +<<<<<<< HEAD + Box::new(move |path| filters.iter().any(|f| path.to_string_lossy().contains(f))) +======= + Box::new(move |path| { + filters.is_empty() + || filters + .iter() + .any(|f| path.file_stem().map_or(false, |stem| stem == f.as_str())) + }) +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= Box::new(move |path| filters.iter().any(|f| path.to_string_lossy().contains(f))) +>>>>>>> 8647e2915 (Use substring matching for TESTNAME) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + Box::new(move |path| filters.iter().any(|f| path.to_string_lossy().contains(f))) +>>>>>>> 615b25c20 (Rebase attempt number 2) } else { Box::new(|_| true) } @@ -218,6 +281,19 @@ fn run_ui_toml() { config.stderr_filter( ®ex::escape( &fs::canonicalize("tests") +<<<<<<< HEAD +======= +<<<<<<< HEAD + &fs::canonicalize("tests") +======= + &std::path::Path::new(file!()) + .parent() + .unwrap() + .canonicalize() +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) .unwrap() .parent() .unwrap() @@ -254,8 +330,27 @@ fn run_ui_cargo() { } let mut config = base_config("ui-cargo"); +<<<<<<< HEAD +<<<<<<< HEAD + config.program.input_file_flag = CommandBuilder::cargo().input_file_flag; + config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag; +======= +<<<<<<< HEAD +<<<<<<< HEAD config.program.input_file_flag = CommandBuilder::cargo().input_file_flag; config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag; +======= + config.program = CommandBuilder::cargo(); +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= + config.program.input_file_flag = CommandBuilder::cargo().input_file_flag; + config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag; +>>>>>>> 0a87ce866 (Find the right `cargo-clippy` binary in CI) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + config.program.input_file_flag = CommandBuilder::cargo().input_file_flag; + config.program.out_dir_flag = CommandBuilder::cargo().out_dir_flag; +>>>>>>> 615b25c20 (Rebase attempt number 2) config.program.args = vec!["clippy".into(), "--color".into(), "never".into(), "--quiet".into()]; config .program @@ -263,7 +358,14 @@ fn run_ui_cargo() { .push(("RUSTFLAGS".into(), Some("-Dwarnings".into()))); // We need to do this while we still have a rustc in the `program` field. config.fill_host_and_target().unwrap(); +<<<<<<< HEAD +<<<<<<< HEAD + config.dependencies_crate_manifest_path = None; +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= config.dependencies_crate_manifest_path = None; +>>>>>>> 615b25c20 (Rebase attempt number 2) config.program.program.set_file_name(if cfg!(windows) { "cargo-clippy.exe" } else { @@ -274,6 +376,19 @@ fn run_ui_cargo() { config.stderr_filter( ®ex::escape( &fs::canonicalize("tests") +<<<<<<< HEAD +======= +<<<<<<< HEAD + &fs::canonicalize("tests") +======= + &std::path::Path::new(file!()) + .parent() + .unwrap() + .canonicalize() +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) .unwrap() .parent() .unwrap() @@ -302,6 +417,16 @@ fn run_ui_cargo() { } fn main() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 95ab05de2 (Fix compile-test under cargo nextest) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Support being run by cargo nextest - https://nexte.st/book/custom-test-harnesses.html if env::args().any(|arg| arg == "--list") { if !env::args().any(|arg| arg == "--ignored") { @@ -311,6 +436,17 @@ fn main() { return; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= +>>>>>>> 95ab05de2 (Fix compile-test under cargo nextest) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) set_var("CLIPPY_DISABLE_DOCS_LINKS", "true"); // The SPEEDTEST_* env variables can be used to check Clippy's performance on your PR. It runs the // affected test 1000 times and gets the average. @@ -427,6 +563,19 @@ fn rustfix_coverage_known_exceptions_accuracy() { let rs_path = Path::new("tests/ui").join(filename); assert!(rs_path.exists(), "`{}` does not exist", rs_path.display()); let fixed_path = rs_path.with_extension("fixed"); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + println!("{}", fixed_path.display()); +>>>>>>> 514b6d04b (Port clippy away from compiletest to ui_test) +======= +>>>>>>> 76de5560f (Add BLESS for compile-test and some cleanup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) assert!(!fixed_path.exists(), "`{}` exists", fixed_path.display()); } } diff --git a/tests/ui-internal/check_formulation.rs b/tests/ui-internal/check_formulation.rs index 43fc996033ea..dc4108dfe8ab 100644 --- a/tests/ui-internal/check_formulation.rs +++ b/tests/ui-internal/check_formulation.rs @@ -38,6 +38,16 @@ declare_tool_lint! { report_in_external_macro: true } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 50c93bbfd (refactor(test): Move attribute to lint level) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_tool_lint! { /// # What it does /// Detects uses of incorrect formulations (allowed with attribute) @@ -49,6 +59,17 @@ declare_tool_lint! { report_in_external_macro: true } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7ac15f900 (Add lint to check lint formulation messages) +======= +>>>>>>> 50c93bbfd (refactor(test): Move attribute to lint level) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) declare_lint_pass!(Pass => [VALID, INVALID1, INVALID2]); fn main() {} diff --git a/tests/ui-internal/custom_ice_message.stderr b/tests/ui-internal/custom_ice_message.stderr index b88aeae2a9b8..1cc37d7909c3 100644 --- a/tests/ui-internal/custom_ice_message.stderr +++ b/tests/ui-internal/custom_ice_message.stderr @@ -10,4 +10,14 @@ note: rustc running on note: compiler flags: -Z ui-testing note: Clippy version: foo +<<<<<<< HEAD +======= +<<<<<<< HEAD + +note: Clippy version: foo +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui-toml/bad_toml/conf_bad_toml.stderr b/tests/ui-toml/bad_toml/conf_bad_toml.stderr index f7d53763a438..56674cbe5b6d 100644 --- a/tests/ui-toml/bad_toml/conf_bad_toml.stderr +++ b/tests/ui-toml/bad_toml/conf_bad_toml.stderr @@ -1,5 +1,21 @@ error: error reading Clippy's configuration file: expected `.`, `=` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:1:4 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:1:4 +======= + --> $DIR/clippy.toml:1:4 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:1:4 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:1:4 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | fn this_is_obviously(not: a, toml: file) { | ^ diff --git a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr index fb0a14081524..3aa59c65c3ae 100644 --- a/tests/ui-toml/bad_toml_type/conf_bad_type.stderr +++ b/tests/ui-toml/bad_toml_type/conf_bad_type.stderr @@ -1,5 +1,21 @@ error: error reading Clippy's configuration file: invalid type: integer `42`, expected a sequence +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:1:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:1:20 +======= + --> $DIR/clippy.toml:1:20 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:1:20 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:1:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | disallowed-names = 42 | ^^ diff --git a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr index 89d84eb24556..ae8fdc10a1a5 100644 --- a/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr +++ b/tests/ui-toml/conf_deprecated_key/conf_deprecated_key.stderr @@ -1,11 +1,43 @@ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:2:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= + --> $DIR/clippy.toml:2:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cyclomatic-complexity-threshold = 2 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `blacklisted-names`. Please use `disallowed-names` instead +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:3:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:3:1 +======= + --> $DIR/clippy.toml:3:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | blacklisted-names = [ "..", "wibble" ] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr index 7c56dfdb948e..72e91ed97d4d 100644 --- a/tests/ui-toml/duplicated_keys/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys/duplicated_keys.stderr @@ -1,5 +1,21 @@ error: error reading Clippy's configuration file: duplicate key `cognitive-complexity-threshold` in document root +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:2:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= + --> $DIR/clippy.toml:2:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cognitive-complexity-threshold = 4 | ^ diff --git a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr index 0af8c0add6c6..dadb935c88bc 100644 --- a/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated/duplicated_keys.stderr @@ -1,11 +1,43 @@ error: error reading Clippy's configuration file: duplicate field `cognitive_complexity_threshold` (provided as `cyclomatic_complexity_threshold`) +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:3:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:3:1 +======= + --> $DIR/clippy.toml:3:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:3:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:3:1 +======= + --> $DIR/clippy.toml:3:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/$DIR/clippy.toml:3:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr index a4b1e9c335ca..8a52d828baec 100644 --- a/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr +++ b/tests/ui-toml/duplicated_keys_deprecated_2/duplicated_keys.stderr @@ -1,11 +1,43 @@ error: error reading Clippy's configuration file: duplicate field `cognitive-complexity-threshold` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/$DIR/clippy.toml:4:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:4:1 +======= + --> $DIR/clippy.toml:4:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:4:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:4:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cognitive-complexity-threshold = 4 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ warning: error reading Clippy's configuration file: deprecated field `cyclomatic-complexity-threshold`. Please use `cognitive-complexity-threshold` instead +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= + --> $DIR/clippy.toml:2:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | cyclomatic-complexity-threshold = 3 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs b/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs index 60fbaaea3d34..586ff0341420 100644 --- a/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs +++ b/tests/ui-toml/excessive_nesting/auxiliary/proc_macros.rs @@ -1,8 +1,38 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // NOTE: Copied from `ui/auxiliary/proc_macros.rs`, couldn't get `../` to work for some reason #![feature(let_chains)] #![feature(proc_macro_span)] #![allow(clippy::excessive_nesting, dead_code)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +//@compile-flags: --emit=link +//@no-prefer-dynamic + +======= +>>>>>>> 5bd97ac17 (Update tests) +// NOTE: Copied from `ui/auxiliary/proc_macros.rs`, couldn't get `../` to work for some reason + +#![feature(let_chains)] +#![feature(proc_macro_span)] +<<<<<<< HEAD +#![allow(dead_code)] +>>>>>>> 5da34559e (Check if from proc macro and better tests) +======= +#![allow(clippy::excessive_nesting, dead_code)] +>>>>>>> 6afb3555d (remove revisions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macro; diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.rs b/tests/ui-toml/excessive_nesting/excessive_nesting.rs index c28220b973ec..97bec49f5e67 100644 --- a/tests/ui-toml/excessive_nesting/excessive_nesting.rs +++ b/tests/ui-toml/excessive_nesting/excessive_nesting.rs @@ -1,4 +1,41 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:macro_rules.rs +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +//@revisions: below default +//@[below] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/below +======= +//@revisions: set default +//@[set] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/set +>>>>>>> 725399a17 (move to `complexity` but don't lint by default) +//@[default] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/default +>>>>>>> 378d77584 (work with lint attributes) +======= +//@aux-build:proc_macros.rs +<<<<<<< HEAD +//@revisions: set above +//@[set] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/set +//@[above] rustc-env:CLIPPY_CONF_DIR=tests/ui-toml/excessive_nesting/above +>>>>>>> 5da34559e (Check if from proc macro and better tests) +======= +>>>>>>> 6afb3555d (remove revisions) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![rustfmt::skip] #![feature(custom_inner_attributes)] #![allow(unused)] @@ -7,12 +44,43 @@ #![allow(clippy::no_effect)] #![allow(clippy::unnecessary_operation)] #![allow(clippy::never_loop)] +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_if)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_if)] +======= +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= #![allow(clippy::needless_if)] +>>>>>>> 7ba904245 (make cargo test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_if)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::excessive_nesting)] #![allow(clippy::collapsible_if)] #[macro_use] +<<<<<<< HEAD +<<<<<<< HEAD +extern crate proc_macros; +======= +<<<<<<< HEAD +<<<<<<< HEAD +extern crate proc_macros; +======= +extern crate macro_rules; +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= extern crate proc_macros; +>>>>>>> 5da34559e (Check if from proc macro and better tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +extern crate proc_macros; +>>>>>>> 615b25c20 (Rebase attempt number 2) static X: u32 = { let x = { @@ -40,7 +108,23 @@ macro_rules! xx { { { { +<<<<<<< HEAD +<<<<<<< HEAD + println!("ehe"); // should not lint +======= +<<<<<<< HEAD +<<<<<<< HEAD println!("ehe"); // should not lint +======= + println!("ehe"); +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + println!("ehe"); // should not lint +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + println!("ehe"); // should not lint +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } @@ -78,7 +162,23 @@ trait Lol { fn lmao() { fn bb() { fn cc() { +<<<<<<< HEAD +<<<<<<< HEAD + let x = { 1 }; // not a warning, but cc is +======= +<<<<<<< HEAD +<<<<<<< HEAD + let x = { 1 }; // not a warning, but cc is +======= + let x = { 1 }; // not a warning +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + let x = { 1 }; // not a warning, but cc is +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let x = { 1 }; // not a warning, but cc is +>>>>>>> 615b25c20 (Rebase attempt number 2) } let x = { 1 }; // warning @@ -86,9 +186,30 @@ trait Lol { } } +<<<<<<< HEAD +<<<<<<< HEAD #[allow(clippy::excessive_nesting)] fn l() {{{{{{{{{}}}}}}}}} +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[allow(clippy::excessive_nesting)] +fn l() {{{{{{{{{}}}}}}}}} + +======= +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +#[allow(clippy::excessive_nesting)] +fn l() {{{{{{{{{}}}}}}}}} + +>>>>>>> 378d77584 (work with lint attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[allow(clippy::excessive_nesting)] +fn l() {{{{{{{{{}}}}}}}}} + +>>>>>>> 615b25c20 (Rebase attempt number 2) use a::{b::{c::{d::{e::{f::{}}}}}}; // should not lint pub mod a { @@ -97,8 +218,28 @@ pub mod a { pub mod d { pub mod e { pub mod f {} +<<<<<<< HEAD +<<<<<<< HEAD + } // not here + } // only warning should be here +======= +<<<<<<< HEAD +<<<<<<< HEAD + } // not here + } // only warning should be here +======= + } + } +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= } // not here } // only warning should be here +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + } // not here + } // only warning should be here +>>>>>>> 615b25c20 (Rebase attempt number 2) } } } @@ -138,6 +279,16 @@ fn main() { x })(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5da34559e (Check if from proc macro and better tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) external! { {{{{{{{{{{{{{{{{}}}}}}}}}}}}}}}} }; // ensure this isn't linted in external macros with_span! { span {{{{{{{{{{{{}}}}}}}}}}}} }; // don't lint for proc macros xx!(); // ensure this is never linted @@ -145,6 +296,23 @@ fn main() { !{boo as u32 + !{boo as u32 + !{boo as u32}}}; // this is a mess, but that's intentional +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + excessive_nesting!(); // ensure this isn't linted in external macros + xx!(); // ensure this is never linted + let boo = true; + !{boo as u32 + !{boo as u32 + !{boo as u32}}}; + +<<<<<<< HEAD +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + // this is a mess, but that's intentional +>>>>>>> 88143ac29 (decided against reinventing the wheel) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut y = 1; y += {{{{{5}}}}}; let z = y + {{{{{{{{{5}}}}}}}}}; diff --git a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr index 1a7311b33e86..42cf45053b46 100644 --- a/tests/ui-toml/excessive_nesting/excessive_nesting.stderr +++ b/tests/ui-toml/excessive_nesting/excessive_nesting.stderr @@ -1,19 +1,164 @@ error: this block is too nested +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 7ba904245 (make cargo test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/excessive_nesting.rs:21:25 | LL | let w = { 3 }; | ^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/auxiliary/mod.rs:6:13 + | +LL | / mod d { +LL | | mod e {} +LL | | } + | |_____________^ +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) +======= + --> $DIR/excessive_nesting.rs:23:25 +======= + --> $DIR/excessive_nesting.rs:20:25 +>>>>>>> 6afb3555d (remove revisions):tests/ui-toml/excessive_nesting/excessive_nesting.stderr + | +LL | let w = { 3 }; + | ^^^^^ +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | = help: try refactoring your code to minimize nesting = note: `-D clippy::excessive-nesting` implied by `-D warnings` error: this block is too nested +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +<<<<<<< HEAD +======= +>>>>>>> 7ba904245 (make cargo test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/excessive_nesting.rs:67:17 | LL | / impl C { LL | | pub fn c() {} LL | | } | |_________________^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/auxiliary/mod.rs:15:7 + | +LL | {{{}}} + | ^^ +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested +<<<<<<< HEAD + --> $DIR/excessive_nesting.rs:81:25 + | +LL | let x = { 1 }; // not a warning, but cc is + | ^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:98:17 + | +LL | / pub mod e { +LL | | pub mod f {} +LL | | } // not here + | |_________________^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:111:18 + | +LL | a_but_not({{{{{{{{0}}}}}}}}); + | ^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:112:12 + | +LL | a.a({{{{{{{{{0}}}}}}}}}); + | ^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:113:12 + | +LL | (0, {{{{{{{1}}}}}}}); + | ^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:118:25 + | +LL | if true { + | _________________________^ +======= + --> $DIR/excessive_nesting.rs:19:21 +======= + --> $DIR/excessive_nesting.rs:21:21 +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) + | +LL | let z = { + | _____________________^ +LL | | let w = { 3 }; +LL | | w +LL | | }; + | |_____________^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:65:24 + | +LL | pub fn b() { + | ________________________^ +LL | | struct C; +LL | | +LL | | impl C { +======= + --> $DIR/excessive_nesting.rs:69:17 +======= + --> $DIR/excessive_nesting.rs:66:17 +>>>>>>> 6afb3555d (remove revisions):tests/ui-toml/excessive_nesting/excessive_nesting.stderr + | +LL | / impl C { +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +LL | | pub fn c() {} +LL | | } + | |_________________^ +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | = help: try refactoring your code to minimize nesting @@ -62,18 +207,120 @@ LL | (0, {{{{{{{1}}}}}}}); error: this block is too nested --> $DIR/excessive_nesting.rs:118:25 | +<<<<<<< HEAD +<<<<<<< HEAD LL | if true { | _________________________^ +======= +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +LL | if true { + | _____________________^ +LL | | if true { +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +LL | if true { + | _________________________^ +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +LL | if true { + | _________________________^ +>>>>>>> 615b25c20 (Rebase attempt number 2) LL | | if true { LL | | LL | | } LL | | } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + | |_________________^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + --> $DIR/excessive_nesting.rs:130:29 + | +LL | let z = (|| { + | _____________________________^ +LL | | let w = { 3 }; +LL | | w +LL | | })(); + | |_________________^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:149:13 + | +LL | y += {{{{{5}}}}}; + | ^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:150:20 + | +LL | let z = y + {{{{{{{{{5}}}}}}}}}; + | ^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:151:12 + | +LL | [0, {{{{{{{{{{0}}}}}}}}}}]; + | ^^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:152:25 + | +LL | let mut xx = [0; {{{{{{{{100}}}}}}}}]; + | ^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:153:11 + | +LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +LL | | } + | |_____________^ +======= | |_________________^ +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr | = help: try refactoring your code to minimize nesting error: this block is too nested + --> $DIR/excessive_nesting.rs:132:29 +======= + --> $DIR/excessive_nesting.rs:129:29 +>>>>>>> 6afb3555d (remove revisions):tests/ui-toml/excessive_nesting/excessive_nesting.stderr +======= --> $DIR/excessive_nesting.rs:130:29 +>>>>>>> 7ba904245 (make cargo test pass) | LL | let z = (|| { | _____________________________^ @@ -123,6 +370,9 @@ LL | xx[{{{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}}}]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: try refactoring your code to minimize nesting +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: this block is too nested --> $DIR/excessive_nesting.rs:154:13 @@ -162,6 +412,58 @@ error: this block is too nested LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} | ^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + = help: try refactoring your code, extraction is often both easier to read and less nested +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= + = help: try refactoring your code to minimize nesting +>>>>>>> 88143ac29 (decided against reinventing the wheel) + +error: this block is too nested + --> $DIR/excessive_nesting.rs:160:14 + | +<<<<<<< HEAD +LL | &mut {{{{{{{{{{y}}}}}}}}}}; + | ^^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:156:17 + | +LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} + | ^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:156:28 + | +LL | for i in {{{{xx}}}} {{{{{{{{}}}}}}}} + | ^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:158:28 + | +LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} + | ^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:158:48 + | +LL | while let Some(i) = {{{{{{Some(1)}}}}}} {{{{{{{}}}}}}} + | ^^^^^^^^ + | +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) = help: try refactoring your code to minimize nesting error: this block is too nested @@ -296,19 +598,224 @@ LL | | } error: this block is too nested --> $DIR/excessive_nesting.rs:190:28 +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} + | ^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:160:35 + | +LL | while {{{{{{{{true}}}}}}}} {{{{{{{{{}}}}}}}}} + | ^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:162:23 + | +LL | let d = D { d: {{{{{{{{{{{{{{{{{{{{{{{3}}}}}}}}}}}}}}}}}}}}}}} }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:164:8 + | +LL | {{{{1;}}}}..{{{{{{3}}}}}}; + | ^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:164:20 + | +LL | {{{{1;}}}}..{{{{{{3}}}}}}; + | ^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:165:8 + | +LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; + | ^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:165:21 + | +LL | {{{{1;}}}}..={{{{{{{{{{{{{{{{{{{{{{{{{{6}}}}}}}}}}}}}}}}}}}}}}}}}}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:166:10 + | +LL | ..{{{{{{{5}}}}}}}; + | ^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:167:11 + | +LL | ..={{{{{3}}}}}; + | ^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:168:8 + | +LL | {{{{{1;}}}}}..; + | ^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:170:20 + | +LL | loop { break {{{{1}}}} }; + | ^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:171:13 + | +LL | loop {{{{{{}}}}}} + | ^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:173:14 + | +LL | match {{{{{{true}}}}}} { + | ^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:174:20 + | +LL | true => {{{{}}}}, + | ^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:175:21 + | +LL | false => {{{{}}}}, + | ^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:181:17 + | +LL | / { +LL | | println!("warning! :)"); +LL | | } + | |_________________^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested + --> $DIR/excessive_nesting.rs:190:28 +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + | +LL | async fn c() -> u32 {{{{{{{0}}}}}}} + | ^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: this block is too nested +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/excessive_nesting.rs:196:8 +======= +<<<<<<< HEAD +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/excessive_nesting.rs:184:28 +>>>>>>> e68dbc330 (add `excessive_nesting`) | LL | async fn c() -> u32 {{{{{{{0}}}}}}} | ^^^^^^^^^ | +<<<<<<< HEAD = help: try refactoring your code to minimize nesting error: this block is too nested --> $DIR/excessive_nesting.rs:196:8 +======= + --> $DIR/excessive_nesting.rs:195:8 +>>>>>>> 6afb3555d (remove revisions):tests/ui-toml/excessive_nesting/excessive_nesting.stderr +======= + --> $DIR/excessive_nesting.rs:196:8 +>>>>>>> 7ba904245 (make cargo test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/excessive_nesting.rs:196:8 +>>>>>>> 615b25c20 (Rebase attempt number 2) + | +LL | {{{{b().await}}}}; + | ^^^^^^^^^^^ + | + = help: try refactoring your code to minimize nesting + +error: aborting due to 37 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + = help: try refactoring your code, extraction is often both easier to read and less nested + +error: this block is too nested + --> $DIR/excessive_nesting.rs:190:7 +======= + --> $DIR/excessive_nesting.rs:191:7 +>>>>>>> 88143ac29 (decided against reinventing the wheel) +======= + --> $DIR/excessive_nesting.rs:193:7 +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) +======= + --> $DIR/excessive_nesting.rs:196:7 +>>>>>>> 378d77584 (work with lint attributes) +======= + --> $DIR/excessive_nesting.rs:198:8 +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr | LL | {{{{b().await}}}}; | ^^^^^^^^^^^ | = help: try refactoring your code to minimize nesting +<<<<<<< HEAD:tests/ui-toml/excessive_nesting/excessive_nesting.stderr +<<<<<<< HEAD +error: aborting due to 40 previous errors +>>>>>>> e68dbc330 (add `excessive_nesting`) +======= +error: aborting due to 41 previous errors +>>>>>>> 493a23e95 (check non-inline modules, ignore all macros) +======= error: aborting due to 37 previous errors +>>>>>>> 5da34559e (Check if from proc macro and better tests):tests/ui-toml/excessive_nesting/excessive_nesting.above.stderr +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.rs b/tests/ui-toml/min_ident_chars/min_ident_chars.rs index 4326c7159c83..1bc29babb0af 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.rs +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.rs @@ -14,6 +14,24 @@ fn main() { let wha = 1; let vvv = 1; let uuu = 1; +<<<<<<< HEAD +<<<<<<< HEAD let (mut a, mut b) = (1, 2); for i in 0..1000 {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + let (mut a, mut b) = (1, 2); + for i in 0..1000 {} +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + let (mut a, mut b) = (1, 2); + for i in 0..1000 {} +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let (mut a, mut b) = (1, 2); + for i in 0..1000 {} +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr index d9a27628ddb2..b8552d873fbb 100644 --- a/tests/ui-toml/min_ident_chars/min_ident_chars.stderr +++ b/tests/ui-toml/min_ident_chars/min_ident_chars.stderr @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: this ident is too short (3 <= 3) +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: this ident is too short (3 <= 3) +======= +error: this ident is too short (3 <= 3) +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +error: this ident is too short (3 <= 3) +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: this ident is too short (3 <= 3) +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/min_ident_chars.rs:6:19 | LL | use extern_types::Aaa; @@ -6,12 +22,38 @@ LL | use extern_types::Aaa; | = note: `-D clippy::min-ident-chars` implied by `-D warnings` +<<<<<<< HEAD +<<<<<<< HEAD +error: this ident is too short (3 <= 3) +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: this ident is too short (3 <= 3) +======= +error: this ident is too short (3 <= 3) +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +error: this ident is too short (3 <= 3) +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: this ident is too short (3 <= 3) +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/min_ident_chars.rs:10:5 | LL | aaa: Aaa, | ^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: this ident is too short (3 <= 3) --> $DIR/min_ident_chars.rs:15:9 | @@ -43,4 +85,16 @@ LL | for i in 0..1000 {} | ^ error: aborting due to 7 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 2 previous errors +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui-toml/suppress_lint_in_const/test.stderr b/tests/ui-toml/suppress_lint_in_const/test.stderr index 14e13194427c..6a65dcd09b9f 100644 --- a/tests/ui-toml/suppress_lint_in_const/test.stderr +++ b/tests/ui-toml/suppress_lint_in_const/test.stderr @@ -1,17 +1,65 @@ error[E0080]: evaluation of `main::{constant#3}` failed +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/test.rs:37:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:37:14 +======= + --> $DIR/test.rs:36:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:37:14 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/test.rs:37:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^ index out of bounds: the length is 2 but the index is 4 note: erroneous constant used +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:37:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:37:5 +======= + --> $DIR/test.rs:36:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:37:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/test.rs:37:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | const { &ARR[idx4()] }; // Ok, should not produce stderr, since `suppress-restriction-lint-in-const` is set true. | ^^^^^^^^^^^^^^^^^^^^^^ error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/test.rs:28:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:28:5 +======= + --> $DIR/test.rs:27:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:28:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/test.rs:28:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | x[index]; | ^^^^^^^^ @@ -20,7 +68,23 @@ LL | x[index]; = note: `-D clippy::indexing-slicing` implied by `-D warnings` error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:46:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:46:5 +======= + --> $DIR/test.rs:43:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:46:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/test.rs:46:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | v[0]; | ^^^^ @@ -28,7 +92,23 @@ LL | v[0]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/test.rs:47:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:47:5 +======= + --> $DIR/test.rs:44:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:47:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/test.rs:47:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | v[10]; | ^^^^^ @@ -36,7 +116,23 @@ LL | v[10]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:48:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:48:5 +======= + --> $DIR/test.rs:45:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:48:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/test.rs:48:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | v[1 << 3]; | ^^^^^^^^^ @@ -44,7 +140,23 @@ LL | v[1 << 3]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/test.rs:54:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:54:5 +======= + --> $DIR/test.rs:51:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:54:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/test.rs:54:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | v[N]; | ^^^^ @@ -52,7 +164,23 @@ LL | v[N]; = help: consider using `.get(n)` or `.get_mut(n)` instead error: indexing may panic +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:55:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/test.rs:55:5 +======= + --> $DIR/test.rs:52:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/test.rs:55:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/test.rs:55:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | v[M]; | ^^^^ diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs index 63fdea710cb6..b82a8b2c8e0f 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.rs @@ -1,6 +1,22 @@ //@compile-flags: --crate-name conf_disallowed_methods +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_raw_strings)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_raw_strings)] +======= +#![allow(clippy::needless_raw_string)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![allow(clippy::needless_raw_strings)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_raw_strings)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::disallowed_methods)] #![allow(clippy::useless_vec)] diff --git a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr index fc137c225d83..bee755e9cd23 100644 --- a/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr +++ b/tests/ui-toml/toml_disallowed_methods/conf_disallowed_methods.stderr @@ -1,5 +1,21 @@ error: use of a disallowed method `regex::Regex::new` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/conf_disallowed_methods.rs:35:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:35:14 +======= + --> $DIR/conf_disallowed_methods.rs:34:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:35:14 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:35:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let re = Regex::new(r"ab.*c").unwrap(); | ^^^^^^^^^^^^^^^^^^^^ @@ -7,7 +23,23 @@ LL | let re = Regex::new(r"ab.*c").unwrap(); = note: `-D clippy::disallowed-methods` implied by `-D warnings` error: use of a disallowed method `regex::Regex::is_match` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:36:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:36:5 +======= + --> $DIR/conf_disallowed_methods.rs:35:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:36:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/conf_disallowed_methods.rs:36:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | re.is_match("abc"); | ^^^^^^^^^^^^^^^^^^ @@ -15,73 +47,265 @@ LL | re.is_match("abc"); = note: no matching allowed (from clippy.toml) error: use of a disallowed method `std::iter::Iterator::sum` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/conf_disallowed_methods.rs:39:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:39:5 +======= + --> $DIR/conf_disallowed_methods.rs:38:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:39:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:39:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | a.iter().sum::(); | ^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `slice::sort_unstable` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:41:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:41:5 +======= + --> $DIR/conf_disallowed_methods.rs:40:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:41:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/conf_disallowed_methods.rs:41:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | a.sort_unstable(); | ^^^^^^^^^^^^^^^^^ error: use of a disallowed method `f32::clamp` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/conf_disallowed_methods.rs:43:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:43:13 +======= + --> $DIR/conf_disallowed_methods.rs:42:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:43:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:43:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = 2.0f32.clamp(3.0f32, 4.0f32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:46:61 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:46:61 +======= + --> $DIR/conf_disallowed_methods.rs:45:61 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:46:61 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/conf_disallowed_methods.rs:46:61 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let indirect: fn(&str) -> Result = Regex::new; | ^^^^^^^^^^ error: use of a disallowed method `f32::clamp` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/conf_disallowed_methods.rs:49:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:49:28 +======= + --> $DIR/conf_disallowed_methods.rs:48:28 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:49:28 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:49:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let in_call = Box::new(f32::clamp); | ^^^^^^^^^^ error: use of a disallowed method `regex::Regex::new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:50:53 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:50:53 +======= + --> $DIR/conf_disallowed_methods.rs:49:53 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/conf_disallowed_methods.rs:50:53 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:50:53 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let in_method_call = ["^", "$"].into_iter().map(Regex::new); | ^^^^^^^^^^ error: use of a disallowed method `futures::stream::select_all` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:53:31 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:53:31 +======= + --> $DIR/conf_disallowed_methods.rs:52:31 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/conf_disallowed_methods.rs:53:31 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:53:31 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let same_name_as_module = select_all(vec![empty::<()>()]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_fn` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:55:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:55:5 +======= + --> $DIR/conf_disallowed_methods.rs:54:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/conf_disallowed_methods.rs:55:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:55:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | local_fn(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::local_mod::f` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:56:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:56:5 +======= + --> $DIR/conf_disallowed_methods.rs:55:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:56:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/conf_disallowed_methods.rs:56:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | local_mod::f(); | ^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Struct::method` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/conf_disallowed_methods.rs:58:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:58:5 +======= + --> $DIR/conf_disallowed_methods.rs:57:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:58:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:58:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | s.method(); | ^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::provided_method` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:59:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:59:5 +======= + --> $DIR/conf_disallowed_methods.rs:58:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/conf_disallowed_methods.rs:59:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/conf_disallowed_methods.rs:59:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | s.provided_method(); | ^^^^^^^^^^^^^^^^^^^ error: use of a disallowed method `conf_disallowed_methods::Trait::implemented_method` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:60:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/conf_disallowed_methods.rs:60:5 +======= + --> $DIR/conf_disallowed_methods.rs:59:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/conf_disallowed_methods.rs:60:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/conf_disallowed_methods.rs:60:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | s.implemented_method(); | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index 6ba26e977302..130163c34303 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -1,4 +1,6 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expected one of +<<<<<<< HEAD +<<<<<<< HEAD accept-comment-above-attributes accept-comment-above-statement allow-dbg-in-tests @@ -9,6 +11,34 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect allow-private-module-inception allow-unwrap-in-tests allowed-idents-below-min-chars +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + accept-comment-above-attributes + accept-comment-above-statement + allow-dbg-in-tests + allow-expect-in-tests + allow-mixed-uninlined-format-args + allow-one-hash-in-raw-strings + allow-print-in-tests + allow-private-module-inception + allow-unwrap-in-tests + allowed-idents-below-min-chars +<<<<<<< HEAD +======= + allowed-idents +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +======= + allowed-idents-below-min-chars +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) allowed-scripts arithmetic-side-effects-allowed arithmetic-side-effects-allowed-binary @@ -62,22 +92,87 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:2:1 +======= + --> $DIR/clippy.toml:2:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/$DIR/clippy.toml:2:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | foobar = 42 | ^^^^^^ error: error reading Clippy's configuration file: unknown field `barfoo`, expected one of +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) accept-comment-above-attributes accept-comment-above-statement allow-dbg-in-tests allow-expect-in-tests allow-mixed-uninlined-format-args +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) allow-one-hash-in-raw-strings allow-print-in-tests allow-private-module-inception allow-unwrap-in-tests allowed-idents-below-min-chars +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= + accept-comment-above-statement +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) + allow-dbg-in-tests + allow-expect-in-tests + allow-mixed-uninlined-format-args +======= + allow-one-hash-in-raw-string +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) + allow-print-in-tests + allow-private-module-inception + allow-unwrap-in-tests +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + allowed-idents +>>>>>>> 52cfc997a (Add lint `single_letter_idents`) +======= + allowed-idents-below-min-chars +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) allowed-scripts arithmetic-side-effects-allowed arithmetic-side-effects-allowed-binary @@ -98,7 +193,22 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect enforced-import-renames enum-variant-name-threshold enum-variant-size-threshold +<<<<<<< HEAD +<<<<<<< HEAD excessive-nesting-threshold +======= +<<<<<<< HEAD +<<<<<<< HEAD + excessive-nesting-threshold +======= +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + excessive-nesting-threshold +>>>>>>> 5da34559e (Check if from proc macro and better tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + excessive-nesting-threshold +>>>>>>> 615b25c20 (Rebase attempt number 2) future-size-threshold ignore-interior-mutability large-error-threshold @@ -109,14 +219,44 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect max-struct-bools max-suggested-slice-pattern-length max-trait-bounds +<<<<<<< HEAD +<<<<<<< HEAD + min-ident-chars-threshold +======= +<<<<<<< HEAD +<<<<<<< HEAD min-ident-chars-threshold +======= +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + min-ident-chars-threshold +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + min-ident-chars-threshold +>>>>>>> 615b25c20 (Rebase attempt number 2) missing-docs-in-crate-items msrv pass-by-value-size-limit semicolon-inside-block-ignore-singleline semicolon-outside-block-ignore-multiline single-char-binding-names-threshold +<<<<<<< HEAD +<<<<<<< HEAD + stack-size-threshold +======= +<<<<<<< HEAD +<<<<<<< HEAD + stack-size-threshold +======= +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= stack-size-threshold +>>>>>>> c8c7a3c79 (fix rebase weirdness) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + stack-size-threshold +>>>>>>> 615b25c20 (Rebase attempt number 2) standard-macro-braces suppress-restriction-lint-in-const third-party @@ -131,7 +271,23 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect vec-box-size-threshold verbose-bit-mask-threshold warn-on-all-wildcard-imports +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:4:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/$DIR/clippy.toml:4:1 +======= + --> $DIR/clippy.toml:4:1 +>>>>>>> 6f13a3749 (Add spans to `clippy.toml` error messages) +======= + --> $DIR/$DIR/clippy.toml:4:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/$DIR/clippy.toml:4:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | barfoo = 53 | ^^^^^^ diff --git a/tests/ui-toml/undocumented_unsafe_blocks/auxiliary/proc_macro_unsafe.rs b/tests/ui-toml/undocumented_unsafe_blocks/auxiliary/proc_macro_unsafe.rs index 1c591fc76f3e..b3190865e0f3 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/auxiliary/proc_macro_unsafe.rs +++ b/tests/ui-toml/undocumented_unsafe_blocks/auxiliary/proc_macro_unsafe.rs @@ -1,3 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +//@compile-flags: --emit=link +//@no-prefer-dynamic + +#![crate_type = "proc-macro"] + +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macro; use proc_macro::{Delimiter, Group, Ident, TokenStream, TokenTree}; diff --git a/tests/ui-toml/undocumented_unsafe_blocks/clippy.toml b/tests/ui-toml/undocumented_unsafe_blocks/clippy.toml index e6dbb3d37841..d5a91801aeb3 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/clippy.toml +++ b/tests/ui-toml/undocumented_unsafe_blocks/clippy.toml @@ -1,2 +1,17 @@ accept-comment-above-statement = true +<<<<<<< HEAD +<<<<<<< HEAD accept-comment-above-attributes = true +======= +<<<<<<< HEAD +<<<<<<< HEAD +accept-comment-above-attributes = true +======= +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +accept-comment-above-attributes = true +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +accept-comment-above-attributes = true +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs index 33d63670958d..149c15ce6674 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs @@ -1,3 +1,12 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@aux-build:proc_macro_unsafe.rs:proc-macro #![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] @@ -508,20 +517,581 @@ fn issue_9142() { bar } }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +#![deny(clippy::undocumented_unsafe_blocks)] +#![allow(clippy::missing_safety_doc)] +======= +//@aux-build:proc_macro_unsafe.rs +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= +//@aux-build:proc_macro_unsafe.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) + +#![warn(clippy::undocumented_unsafe_blocks, clippy::unnecessary_safety_comment)] +#![allow(deref_nullptr, clippy::let_unit_value, clippy::missing_safety_doc)] +#![feature(lint_reasons)] + +extern crate proc_macro_unsafe; + +// Valid comments + +fn nested_local() { + let _ = { + let _ = { + // SAFETY: + let _ = unsafe {}; + }; + }; +} + +fn deep_nest() { + let _ = { + let _ = { + // SAFETY: + let _ = unsafe {}; + + // Safety: + unsafe {}; + + let _ = { + let _ = { + let _ = { + let _ = { + let _ = { + // Safety: + let _ = unsafe {}; + + // SAFETY: + unsafe {}; + }; + }; + }; + + // Safety: + unsafe {}; + }; + }; + }; + + // Safety: + unsafe {}; + }; + + // SAFETY: + unsafe {}; +} + +fn local_tuple_expression() { + // Safety: + let _ = (42, unsafe {}); +} + +fn line_comment() { + // Safety: + unsafe {} +} + +fn line_comment_newlines() { + // SAFETY: + + unsafe {} +} + +fn line_comment_empty() { + // Safety: + // + // + // + unsafe {} +} + +fn line_comment_with_extras() { + // This is a description + // Safety: + unsafe {} +} + +fn block_comment() { + /* Safety: */ + unsafe {} +} + +fn block_comment_newlines() { + /* SAFETY: */ + + unsafe {} +} + +fn block_comment_with_extras() { + /* This is a description + * SAFETY: + */ + unsafe {} +} + +fn block_comment_terminator_same_line() { + /* This is a description + * Safety: */ + unsafe {} +} + +fn buried_safety() { + // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + // incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation + // ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in + // reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint + // occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est + // laborum. Safety: + // Tellus elementum sagittis vitae et leo duis ut diam quam. Sit amet nulla facilisi + // morbi tempus iaculis urna. Amet luctus venenatis lectus magna. At quis risus sed vulputate odio + // ut. Luctus venenatis lectus magna fringilla urna. Tortor id aliquet lectus proin nibh nisl + // condimentum id venenatis. Vulputate dignissim suspendisse in est ante in nibh mauris cursus. + unsafe {} +} + +fn safety_with_prepended_text() { + // This is a test. safety: + unsafe {} +} + +fn local_line_comment() { + // Safety: + let _ = unsafe {}; +} + +fn local_block_comment() { + /* SAFETY: */ + let _ = unsafe {}; +} + +fn comment_array() { + // Safety: + let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; +} + +fn comment_tuple() { + // sAFETY: + let _ = (42, unsafe {}, "test", unsafe {}); +} + +fn comment_unary() { + // SAFETY: + let _ = *unsafe { &42 }; +} + +#[allow(clippy::match_single_binding)] +fn comment_match() { + // SAFETY: + let _ = match unsafe {} { + _ => {}, + }; +} + +fn comment_addr_of() { + // Safety: + let _ = &unsafe {}; +} + +fn comment_repeat() { + // Safety: + let _ = [unsafe {}; 5]; +} + +fn comment_macro_call() { + macro_rules! t { + ($b:expr) => { + $b + }; + } + + t!( + // SAFETY: + unsafe {} + ); +} + +fn comment_macro_def() { + macro_rules! t { + () => { + // Safety: + unsafe {} + }; + } + + t!(); +} + +fn non_ascii_comment() { + // ॐ᧻໒ SaFeTy: ௵∰ + unsafe {}; +} + +fn local_commented_block() { + let _ = + // safety: + unsafe {}; +} + +fn local_nest() { + // safety: + let _ = [(42, unsafe {}, unsafe {}), (52, unsafe {}, unsafe {})]; +} + +fn in_fn_call(x: *const u32) { + fn f(x: u32) {} + + // Safety: reason + f(unsafe { *x }); +} + +fn multi_in_fn_call(x: *const u32) { + fn f(x: u32, y: u32) {} + + // Safety: reason + f(unsafe { *x }, unsafe { *x }); +} + +fn in_multiline_fn_call(x: *const u32) { + fn f(x: u32, y: u32) {} + + f( + // Safety: reason + unsafe { *x }, + 0, + ); +} + +fn in_macro_call(x: *const u32) { + // Safety: reason + println!("{}", unsafe { *x }); +} + +fn in_multiline_macro_call(x: *const u32) { + println!( + "{}", + // Safety: reason + unsafe { *x }, + ); +} + +fn from_proc_macro() { + proc_macro_unsafe::unsafe_block!(token); +} + +fn in_closure(x: *const u32) { + // Safety: reason + let _ = || unsafe { *x }; +} + +// Invalid comments + +#[rustfmt::skip] +fn inline_block_comment() { + /* Safety: */ unsafe {} +} + +fn no_comment() { + unsafe {} +} + +fn no_comment_array() { + let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; +} + +fn no_comment_tuple() { + let _ = (42, unsafe {}, "test", unsafe {}); +} + +fn no_comment_unary() { + let _ = *unsafe { &42 }; +} + +#[allow(clippy::match_single_binding)] +fn no_comment_match() { + let _ = match unsafe {} { + _ => {}, + }; +} + +fn no_comment_addr_of() { + let _ = &unsafe {}; +} + +fn no_comment_repeat() { + let _ = [unsafe {}; 5]; +} + +fn local_no_comment() { + let _ = unsafe {}; +} + +fn no_comment_macro_call() { + macro_rules! t { + ($b:expr) => { + $b + }; + } + + t!(unsafe {}); +} + +fn no_comment_macro_def() { + macro_rules! t { + () => { + unsafe {} + }; + } + + t!(); +} + +fn trailing_comment() { + unsafe {} // SAFETY: +} + +fn internal_comment() { + unsafe { + // SAFETY: + } +} + +fn interference() { + // SAFETY + + let _ = 42; + + unsafe {}; +} + +pub fn print_binary_tree() { + println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); +} + +mod unsafe_impl_smoke_test { + unsafe trait A {} + + // error: no safety comment + unsafe impl A for () {} + + // Safety: ok + unsafe impl A for (i32) {} + + mod sub_mod { + // error: + unsafe impl B for (u32) {} + unsafe trait B {} + } + + #[rustfmt::skip] + mod sub_mod2 { + // + // SAFETY: ok + // + + unsafe impl B for (u32) {} + unsafe trait B {} + } +} + +mod unsafe_impl_from_macro { + unsafe trait T {} + + // error + macro_rules! no_safety_comment { + ($t:ty) => { + unsafe impl T for $t {} + }; + } + + // ok + no_safety_comment!(()); + + // ok + macro_rules! with_safety_comment { + ($t:ty) => { + // SAFETY: + unsafe impl T for $t {} + }; + } + + // ok + with_safety_comment!((i32)); +} + +mod unsafe_impl_macro_and_not_macro { + unsafe trait T {} + + // error + macro_rules! no_safety_comment { + ($t:ty) => { + unsafe impl T for $t {} + }; + } + + // ok + no_safety_comment!(()); + + // error + unsafe impl T for (i32) {} + + // ok + no_safety_comment!(u32); + + // error + unsafe impl T for (bool) {} +} + +#[rustfmt::skip] +mod unsafe_impl_valid_comment { + unsafe trait SaFety {} + // SaFety: + unsafe impl SaFety for () {} + + unsafe trait MultiLineComment {} + // The following impl is safe + // ... + // Safety: reason + unsafe impl MultiLineComment for () {} + + unsafe trait NoAscii {} + // 安全 SAFETY: 以下のコードは安全です + unsafe impl NoAscii for () {} + + unsafe trait InlineAndPrecedingComment {} + // SAFETY: + /* comment */ unsafe impl InlineAndPrecedingComment for () {} + + unsafe trait BuriedSafety {} + // Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor + // incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation + // ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in + // reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint + // occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est + // laborum. Safety: + // Tellus elementum sagittis vitae et leo duis ut diam quam. Sit amet nulla facilisi + // morbi tempus iaculis urna. Amet luctus venenatis lectus magna. At quis risus sed vulputate odio + // ut. Luctus venenatis lectus magna fringilla urna. Tortor id aliquet lectus proin nibh nisl + // condimentum id venenatis. Vulputate dignissim suspendisse in est ante in nibh mauris cursus. + unsafe impl BuriedSafety for () {} + + unsafe trait MultiLineBlockComment {} + /* This is a description + * Safety: */ + unsafe impl MultiLineBlockComment for () {} +} + +#[rustfmt::skip] +mod unsafe_impl_invalid_comment { + unsafe trait NoComment {} + + unsafe impl NoComment for () {} + + unsafe trait InlineComment {} + + /* SAFETY: */ unsafe impl InlineComment for () {} + + unsafe trait TrailingComment {} + + unsafe impl TrailingComment for () {} // SAFETY: + + unsafe trait Interference {} + // SAFETY: + const BIG_NUMBER: i32 = 1000000; + unsafe impl Interference for () {} +} + +unsafe trait ImplInFn {} + +fn impl_in_fn() { + // error + unsafe impl ImplInFn for () {} + + // SAFETY: ok + unsafe impl ImplInFn for (i32) {} +} + +unsafe trait CrateRoot {} + +// error +unsafe impl CrateRoot for () {} + +// SAFETY: ok +unsafe impl CrateRoot for (i32) {} + +fn issue_9142() { + // SAFETY: ok + let _ = + // we need this comment to avoid rustfmt putting + // it all on one line + unsafe {}; + + // SAFETY: this is more than one level away, so it should warn + let _ = { + if unsafe { true } { + todo!(); + } else { + let bar = unsafe {}; + todo!(); + bar + } + }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +} + +pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 { + 1 +} + +pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 { + 2 +} + +fn issue_10832() { + // Safety: A safety comment + let _some_variable_with_a_very_long_name_to_break_the_line = + unsafe { a_function_with_a_very_long_name_to_break_the_line() }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= + + // Safety: Another safety comment + const _SOME_CONST_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 = + unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; + + // Safety: Yet another safety comment + static _SOME_STATIC_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 = + unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; +>>>>>>> e2e6a0244 (Addressing reviewer comments) } pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 { 1 } +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 { 2 } +<<<<<<< HEAD fn issue_10832() { // Safety: A safety comment let _some_variable_with_a_very_long_name_to_break_the_line = unsafe { a_function_with_a_very_long_name_to_break_the_line() }; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Safety: Another safety comment const _SOME_CONST_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 = @@ -532,6 +1102,16 @@ fn issue_10832() { unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn issue_8679() { // SAFETY: #[allow(unsafe_code)] @@ -565,3 +1145,16 @@ fn issue_8679() { } fn main() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +======= +fn main() {} +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr index 9a0fd0593896..2d2c6a4b3e43 100644 --- a/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr +++ b/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.stderr @@ -1,5 +1,21 @@ error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:263:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:263:19 +======= + --> $DIR/undocumented_unsafe_blocks.rs:262:19 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:263:19 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:263:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | /* Safety: */ unsafe {} | ^^^^^^^^^ @@ -8,7 +24,23 @@ LL | /* Safety: */ unsafe {} = note: `-D clippy::undocumented-unsafe-blocks` implied by `-D warnings` error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:267:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:267:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:266:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:267:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:267:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe {} | ^^^^^^^^^ @@ -16,7 +48,23 @@ LL | unsafe {} = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:14 +======= + --> $DIR/undocumented_unsafe_blocks.rs:270:14 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:271:14 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:271:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -24,7 +72,23 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:29 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:29 +======= + --> $DIR/undocumented_unsafe_blocks.rs:270:29 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:271:29 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:271:29 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -32,7 +96,23 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:48 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:271:48 +======= + --> $DIR/undocumented_unsafe_blocks.rs:270:48 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:271:48 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:271:48 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; | ^^^^^^^^^^^^^ @@ -40,7 +120,23 @@ LL | let _ = [unsafe { 14 }, unsafe { 15 }, 42, unsafe { 16 }]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:275:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:275:18 +======= + --> $DIR/undocumented_unsafe_blocks.rs:274:18 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:275:18 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:275:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -48,7 +144,23 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:275:37 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:275:37 +======= + --> $DIR/undocumented_unsafe_blocks.rs:274:37 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:275:37 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:275:37 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = (42, unsafe {}, "test", unsafe {}); | ^^^^^^^^^ @@ -56,7 +168,23 @@ LL | let _ = (42, unsafe {}, "test", unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:279:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:279:14 +======= + --> $DIR/undocumented_unsafe_blocks.rs:278:14 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:279:14 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:279:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = *unsafe { &42 }; | ^^^^^^^^^^^^^^ @@ -64,7 +192,23 @@ LL | let _ = *unsafe { &42 }; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:284:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:284:19 +======= + --> $DIR/undocumented_unsafe_blocks.rs:283:19 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:284:19 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:284:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = match unsafe {} { | ^^^^^^^^^ @@ -72,7 +216,23 @@ LL | let _ = match unsafe {} { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:290:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:290:14 +======= + --> $DIR/undocumented_unsafe_blocks.rs:289:14 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:290:14 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:290:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = &unsafe {}; | ^^^^^^^^^ @@ -80,7 +240,23 @@ LL | let _ = &unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:294:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:294:14 +======= + --> $DIR/undocumented_unsafe_blocks.rs:293:14 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:294:14 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:294:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = [unsafe {}; 5]; | ^^^^^^^^^ @@ -88,7 +264,23 @@ LL | let _ = [unsafe {}; 5]; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:298:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:298:13 +======= + --> $DIR/undocumented_unsafe_blocks.rs:297:13 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:298:13 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:298:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = unsafe {}; | ^^^^^^^^^ @@ -96,7 +288,23 @@ LL | let _ = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:308:8 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:308:8 +======= + --> $DIR/undocumented_unsafe_blocks.rs:307:8 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:308:8 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:308:8 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | t!(unsafe {}); | ^^^^^^^^^ @@ -104,7 +312,23 @@ LL | t!(unsafe {}); = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:314:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:314:13 +======= + --> $DIR/undocumented_unsafe_blocks.rs:313:13 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:314:13 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:314:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe {} | ^^^^^^^^^ @@ -116,7 +340,23 @@ LL | t!(); = note: this error originates in the macro `t` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:322:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:322:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:321:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:322:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:322:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe {} // SAFETY: | ^^^^^^^^^ @@ -124,7 +364,23 @@ LL | unsafe {} // SAFETY: = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:326:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:326:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:325:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:326:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:326:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe { | ^^^^^^^^ @@ -132,7 +388,23 @@ LL | unsafe { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:336:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:336:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:335:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:336:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:336:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe {}; | ^^^^^^^^^ @@ -140,7 +412,23 @@ LL | unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:340:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:340:20 +======= + --> $DIR/undocumented_unsafe_blocks.rs:339:20 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:340:20 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:340:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -148,7 +436,23 @@ LL | println!("{}", unsafe { String::from_utf8_unchecked(vec![]) }); = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:347:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:347:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:346:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:347:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:347:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl A for () {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +460,23 @@ LL | unsafe impl A for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:354:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:354:9 +======= + --> $DIR/undocumented_unsafe_blocks.rs:353:9 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:354:9 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:354:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl B for (u32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -164,7 +484,23 @@ LL | unsafe impl B for (u32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:375:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:375:13 +======= + --> $DIR/undocumented_unsafe_blocks.rs:374:13 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:375:13 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:375:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -176,7 +512,23 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +======= + --> $DIR/undocumented_unsafe_blocks.rs:399:13 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:400:13 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -188,7 +540,23 @@ LL | no_safety_comment!(()); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:408:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:408:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:407:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:408:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:408:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl T for (i32) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -196,7 +564,23 @@ LL | unsafe impl T for (i32) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +======= + --> $DIR/undocumented_unsafe_blocks.rs:399:13 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:400:13 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:400:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl T for $t {} | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -208,7 +592,23 @@ LL | no_safety_comment!(u32); = note: this error originates in the macro `no_safety_comment` (in Nightly builds, run with -Z macro-backtrace for more info) error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:414:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:414:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:413:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:414:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:414:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl T for (bool) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -216,7 +616,23 @@ LL | unsafe impl T for (bool) {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:460:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:460:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:459:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:460:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:460:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl NoComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,7 +640,23 @@ LL | unsafe impl NoComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:464:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:464:19 +======= + --> $DIR/undocumented_unsafe_blocks.rs:463:19 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:464:19 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:464:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | /* SAFETY: */ unsafe impl InlineComment for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -232,7 +664,23 @@ LL | /* SAFETY: */ unsafe impl InlineComment for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:468:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:468:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:467:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:468:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:468:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl TrailingComment for () {} // SAFETY: | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -240,20 +688,68 @@ LL | unsafe impl TrailingComment for () {} // SAFETY: = help: consider adding a safety comment on the preceding line error: constant item has unnecessary safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:472:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:472:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:471:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:472:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:472:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | const BIG_NUMBER: i32 = 1000000; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: consider removing the safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:471:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:471:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:470:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:471:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:471:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | // SAFETY: | ^^^^^^^^^^ = note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings` error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:473:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:473:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:472:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:473:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:473:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl Interference for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -261,7 +757,23 @@ LL | unsafe impl Interference for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:480:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:480:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:479:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:480:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:480:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl ImplInFn for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -269,7 +781,23 @@ LL | unsafe impl ImplInFn for () {} = help: consider adding a safety comment on the preceding line error: unsafe impl missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:489:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:489:1 +======= + --> $DIR/undocumented_unsafe_blocks.rs:488:1 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:489:1 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:489:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe impl CrateRoot for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -277,7 +805,23 @@ LL | unsafe impl CrateRoot for () {} = help: consider adding a safety comment on the preceding line error: statement has unnecessary safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:502:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:502:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:501:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:502:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:502:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let _ = { LL | | if unsafe { true } { @@ -289,13 +833,45 @@ LL | | }; | |______^ | help: consider removing the safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:501:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:501:5 +======= + --> $DIR/undocumented_unsafe_blocks.rs:500:5 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= --> $DIR/undocumented_unsafe_blocks.rs:501:5 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:501:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | // SAFETY: this is more than one level away, so it should warn | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:503:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:503:12 +======= + --> $DIR/undocumented_unsafe_blocks.rs:502:12 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:503:12 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:503:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if unsafe { true } { | ^^^^^^^^^^^^^^^ @@ -303,7 +879,23 @@ LL | if unsafe { true } { = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:506:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:506:23 +======= + --> $DIR/undocumented_unsafe_blocks.rs:505:23 +>>>>>>> 8625a849d (adding all ui tests to the configuration test as well) +======= + --> $DIR/undocumented_unsafe_blocks.rs:506:23 +>>>>>>> cc2e49f69 (allow safety comment above attributes) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/undocumented_unsafe_blocks.rs:506:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let bar = unsafe {}; | ^^^^^^^^^ diff --git a/tests/ui-toml/unwrap_used/unwrap_used.stderr b/tests/ui-toml/unwrap_used/unwrap_used.stderr index 4c9bdfa9dba7..d13251d9a261 100644 --- a/tests/ui-toml/unwrap_used/unwrap_used.stderr +++ b/tests/ui-toml/unwrap_used/unwrap_used.stderr @@ -4,7 +4,27 @@ error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more co LL | let _ = boxed_slice.get(1).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&boxed_slice[1]` | +<<<<<<< HEAD +<<<<<<< HEAD = note: `-D clippy::get-unwrap` implied by `-D warnings` +======= +<<<<<<< HEAD +<<<<<<< HEAD + = note: `-D clippy::get-unwrap` implied by `-D warnings` +======= +note: the lint level is defined here + --> $DIR/unwrap_used.rs:10:9 + | +LL | #![deny(clippy::get_unwrap)] + | ^^^^^^^^^^^^^^^^^^ +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + = note: `-D clippy::get-unwrap` implied by `-D warnings` +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: `-D clippy::get-unwrap` implied by `-D warnings` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap()` on an `Option` value --> $DIR/unwrap_used.rs:38:17 diff --git a/tests/ui/allow_attributes.fixed b/tests/ui/allow_attributes.fixed index cc95a06817d6..ba414f6ab583 100644 --- a/tests/ui/allow_attributes.fixed +++ b/tests/ui/allow_attributes.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused)] #![warn(clippy::allow_attributes)] #![feature(lint_reasons)] @@ -25,7 +41,23 @@ struct CfgT; fn ignore_external() { external! { +<<<<<<< HEAD +<<<<<<< HEAD + #[allow(clippy::needless_borrow)] // Should not lint +======= +<<<<<<< HEAD +<<<<<<< HEAD + #[allow(clippy::needless_borrow)] // Should not lint +======= + #[allow(clippy::needless_borrow)] +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= + #[allow(clippy::needless_borrow)] // Should not lint +>>>>>>> ab70553a3 (foiled again (forgot to run cargo test)) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= #[allow(clippy::needless_borrow)] // Should not lint +>>>>>>> 615b25c20 (Rebase attempt number 2) fn a() {} } } diff --git a/tests/ui/allow_attributes.rs b/tests/ui/allow_attributes.rs index 2eb6ad304ea4..9cd00807348a 100644 --- a/tests/ui/allow_attributes.rs +++ b/tests/ui/allow_attributes.rs @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused)] #![warn(clippy::allow_attributes)] #![feature(lint_reasons)] diff --git a/tests/ui/allow_attributes_without_reason.rs b/tests/ui/allow_attributes_without_reason.rs index d223d5642217..06d947e9eee5 100644 --- a/tests/ui/allow_attributes_without_reason.rs +++ b/tests/ui/allow_attributes_without_reason.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(lint_reasons)] #![deny(clippy::allow_attributes_without_reason)] #![allow(unfulfilled_lint_expectations)] @@ -28,10 +44,34 @@ fn main() { fn b() {} } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + +// Make sure this is not triggered on `?` desugaring + +pub fn trigger_fp_option() -> Option<()> { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= // Make sure this is not triggered on `?` desugaring +<<<<<<< HEAD +pub fn trigger_fp_option() -> Option<()>{ +>>>>>>> 70553711a (add test for `?` desugaring) +======= pub fn trigger_fp_option() -> Option<()> { +>>>>>>> b469e8ce2 (Update allow_attributes_without_reason.rs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Some(())?; None?; Some(()) @@ -42,3 +82,14 @@ pub fn trigger_fp_result() -> Result<(), &'static str> { Err("asdf")?; Ok(()) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 0086b6ab0 (don't lint `allow_attributes` on attributes from proc macros) +======= +>>>>>>> 70553711a (add test for `?` desugaring) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/arc_with_non_send_sync.rs b/tests/ui/arc_with_non_send_sync.rs index b6fcca0a7919..a5606a5f2f10 100644 --- a/tests/ui/arc_with_non_send_sync.rs +++ b/tests/ui/arc_with_non_send_sync.rs @@ -3,6 +3,16 @@ use std::cell::RefCell; use std::sync::{Arc, Mutex}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2f5d1c748 (Adding extra check to ignore generic args.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn foo(x: T) { // Should not lint - purposefully ignoring generic args. let a = Arc::new(x); @@ -11,6 +21,17 @@ fn issue11076() { let a: Arc> = Arc::new(Vec::new()); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= +>>>>>>> 2f5d1c748 (Adding extra check to ignore generic args.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { let _ = Arc::new(42); diff --git a/tests/ui/arc_with_non_send_sync.stderr b/tests/ui/arc_with_non_send_sync.stderr index 7633b38dfb59..2e7ba77bba78 100644 --- a/tests/ui/arc_with_non_send_sync.stderr +++ b/tests/ui/arc_with_non_send_sync.stderr @@ -1,12 +1,63 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: usage of an `Arc` that is not `Send` or `Sync` --> $DIR/arc_with_non_send_sync.rs:18:13 +======= +<<<<<<< HEAD +error: usage of `Arc` where `T` is not `Send` or `Sync` +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arc_with_non_send_sync.rs:16:13 +======= + --> $DIR/arc_with_non_send_sync.rs:11:13 +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= + --> $DIR/arc_with_non_send_sync.rs:16:13 +>>>>>>> 2f5d1c748 (Adding extra check to ignore generic args.) +======= + --> $DIR/arc_with_non_send_sync.rs:19:13 +>>>>>>> 75c339cd0 ([`arc_with_non_send_sync`]: look for nested type parameters) +======= +error: usage of an `Arc` that is not `Send` or `Sync` + --> $DIR/arc_with_non_send_sync.rs:18:13 +>>>>>>> 4939a716e (arc_with_non_send_sync: reword and move to suspicious) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: usage of an `Arc` that is not `Send` or `Sync` + --> $DIR/arc_with_non_send_sync.rs:18:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Arc::new(RefCell::new(42)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = note: the trait `Sync` is not implemented for `RefCell` + = note: required for `Arc>` to implement `Send` and `Sync` + = help: consider using an `Rc` instead or wrapping the inner type with a `Mutex` +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` +======= + = help: consider using `Rc` instead or wrapping `T` in a std::sync type like Mutex +>>>>>>> 339cd14f2 (Adds new lint `arc_with_non_send_or_sync`) +======= + = help: consider using `Rc` instead or wrapping `T` in a std::sync type like `Mutex` +>>>>>>> 2f5d1c748 (Adding extra check to ignore generic args.) +======= + = note: the trait `Sync` is not implemented for `RefCell` + = note: required for `Arc>` to implement `Send` and `Sync` + = help: consider using an `Rc` instead or wrapping the inner type with a `Mutex` +>>>>>>> 4939a716e (arc_with_non_send_sync: reword and move to suspicious) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= = note: the trait `Sync` is not implemented for `RefCell` = note: required for `Arc>` to implement `Send` and `Sync` = help: consider using an `Rc` instead or wrapping the inner type with a `Mutex` +>>>>>>> 615b25c20 (Rebase attempt number 2) = note: `-D clippy::arc-with-non-send-sync` implied by `-D warnings` error: usage of an `Arc` that is not `Send` or `Sync` diff --git a/tests/ui/arithmetic_side_effects.rs b/tests/ui/arithmetic_side_effects.rs index ed75acee8a28..7f155c2d7527 100644 --- a/tests/ui/arithmetic_side_effects.rs +++ b/tests/ui/arithmetic_side_effects.rs @@ -1,4 +1,28 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macro_derive.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macro_derive.rs +======= +// aux-build:proc_macro_derive.rs +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= +//@aux-build:proc_macro_derive.rs +>>>>>>> def1705a2 (Update to a compiletest-rs version that requires `//@` for commands) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::assign_op_pattern, diff --git a/tests/ui/arithmetic_side_effects.stderr b/tests/ui/arithmetic_side_effects.stderr index e9a626643ff7..f81c7872c494 100644 --- a/tests/ui/arithmetic_side_effects.stderr +++ b/tests/ui/arithmetic_side_effects.stderr @@ -1,5 +1,21 @@ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:304:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:304:5 +======= + --> $DIR/arithmetic_side_effects.rs:293:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:304:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:304:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n += 1; | ^^^^^^^ @@ -7,540 +23,1974 @@ LL | _n += 1; = note: `-D clippy::arithmetic-side-effects` implied by `-D warnings` error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:305:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:305:5 +======= + --> $DIR/arithmetic_side_effects.rs:294:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:305:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:305:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n += &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:306:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:306:5 +======= + --> $DIR/arithmetic_side_effects.rs:295:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:306:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:306:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n -= 1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:307:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:307:5 +======= + --> $DIR/arithmetic_side_effects.rs:296:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:307:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:307:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n -= &1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:308:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:308:5 +======= + --> $DIR/arithmetic_side_effects.rs:297:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:308:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:308:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n /= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:309:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:309:5 +======= + --> $DIR/arithmetic_side_effects.rs:298:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:309:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:309:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n /= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:310:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:310:5 +======= + --> $DIR/arithmetic_side_effects.rs:299:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:310:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:310:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n %= 0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:311:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:311:5 +======= + --> $DIR/arithmetic_side_effects.rs:300:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:311:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:311:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n %= &0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:312:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:312:5 +======= + --> $DIR/arithmetic_side_effects.rs:301:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:312:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:312:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n *= 2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:313:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:313:5 +======= + --> $DIR/arithmetic_side_effects.rs:302:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:313:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:313:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n *= &2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:314:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:314:5 +======= + --> $DIR/arithmetic_side_effects.rs:303:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:314:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:314:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n += -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:315:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:315:5 +======= + --> $DIR/arithmetic_side_effects.rs:304:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:315:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:315:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n += &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:316:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:316:5 +======= + --> $DIR/arithmetic_side_effects.rs:305:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:316:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:316:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n -= -1; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:317:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:317:5 +======= + --> $DIR/arithmetic_side_effects.rs:306:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:317:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:317:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n -= &-1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:318:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:318:5 +======= + --> $DIR/arithmetic_side_effects.rs:307:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:318:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:318:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n /= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:319:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:319:5 +======= + --> $DIR/arithmetic_side_effects.rs:308:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:319:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:319:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n /= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:320:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:320:5 +======= + --> $DIR/arithmetic_side_effects.rs:309:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:320:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:320:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n %= -0; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:321:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:321:5 +======= + --> $DIR/arithmetic_side_effects.rs:310:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:321:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:321:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n %= &-0; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:322:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:322:5 +======= + --> $DIR/arithmetic_side_effects.rs:311:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:322:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:322:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n *= -2; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:323:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:323:5 +======= + --> $DIR/arithmetic_side_effects.rs:312:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:323:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:323:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n *= &-2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:324:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:324:5 +======= + --> $DIR/arithmetic_side_effects.rs:313:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:324:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:324:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom += Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:325:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:325:5 +======= + --> $DIR/arithmetic_side_effects.rs:314:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:325:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:325:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom += &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:326:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:326:5 +======= + --> $DIR/arithmetic_side_effects.rs:315:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:326:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:326:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom -= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:327:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:327:5 +======= + --> $DIR/arithmetic_side_effects.rs:316:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:327:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:327:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom -= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:328:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:328:5 +======= + --> $DIR/arithmetic_side_effects.rs:317:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:328:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:328:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom /= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:329:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:329:5 +======= + --> $DIR/arithmetic_side_effects.rs:318:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:329:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:329:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom /= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:330:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:330:5 +======= + --> $DIR/arithmetic_side_effects.rs:319:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:330:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:330:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom %= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:331:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:331:5 +======= + --> $DIR/arithmetic_side_effects.rs:320:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:331:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:331:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom %= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:332:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:332:5 +======= + --> $DIR/arithmetic_side_effects.rs:321:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:332:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:332:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom *= Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:333:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:333:5 +======= + --> $DIR/arithmetic_side_effects.rs:322:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:333:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:333:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom *= &Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:334:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:334:5 +======= + --> $DIR/arithmetic_side_effects.rs:323:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:334:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:334:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom >>= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:335:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:335:5 +======= + --> $DIR/arithmetic_side_effects.rs:324:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:335:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:335:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom >>= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:336:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:336:5 +======= + --> $DIR/arithmetic_side_effects.rs:325:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:336:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:336:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom <<= Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:337:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:337:5 +======= + --> $DIR/arithmetic_side_effects.rs:326:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:337:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:337:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom <<= &Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:338:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:338:5 +======= + --> $DIR/arithmetic_side_effects.rs:327:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:338:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:338:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom += -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:339:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:339:5 +======= + --> $DIR/arithmetic_side_effects.rs:328:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:339:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:339:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom += &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:340:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:340:5 +======= + --> $DIR/arithmetic_side_effects.rs:329:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:340:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:340:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom -= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:341:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:341:5 +======= + --> $DIR/arithmetic_side_effects.rs:330:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:341:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:341:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom -= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:342:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:342:5 +======= + --> $DIR/arithmetic_side_effects.rs:331:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:342:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:342:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom /= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:343:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:343:5 +======= + --> $DIR/arithmetic_side_effects.rs:332:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:343:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:343:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom /= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:344:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:344:5 +======= + --> $DIR/arithmetic_side_effects.rs:333:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:344:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:344:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom %= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:345:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:345:5 +======= + --> $DIR/arithmetic_side_effects.rs:334:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:345:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:345:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom %= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:346:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:346:5 +======= + --> $DIR/arithmetic_side_effects.rs:335:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:346:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:346:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom *= -Custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:347:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:347:5 +======= + --> $DIR/arithmetic_side_effects.rs:336:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:347:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:347:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom *= &-Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:348:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:348:5 +======= + --> $DIR/arithmetic_side_effects.rs:337:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:348:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:348:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom >>= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:349:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:349:5 +======= + --> $DIR/arithmetic_side_effects.rs:338:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:349:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:349:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom >>= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:350:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:350:5 +======= + --> $DIR/arithmetic_side_effects.rs:339:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:350:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:350:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom <<= -Custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:351:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:351:5 +======= + --> $DIR/arithmetic_side_effects.rs:340:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:351:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:351:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom <<= &-Custom; | ^^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:354:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:354:10 +======= + --> $DIR/arithmetic_side_effects.rs:343:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:354:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:354:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n + 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:355:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:355:10 +======= + --> $DIR/arithmetic_side_effects.rs:344:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:355:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:355:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n + &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:356:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:356:10 +======= + --> $DIR/arithmetic_side_effects.rs:345:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:356:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:356:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = 1 + _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:357:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:357:10 +======= + --> $DIR/arithmetic_side_effects.rs:346:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:357:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:357:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = &1 + _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:358:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:358:10 +======= + --> $DIR/arithmetic_side_effects.rs:347:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:358:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:358:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n - 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:359:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:359:10 +======= + --> $DIR/arithmetic_side_effects.rs:348:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:359:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:359:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n - &1; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:360:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:360:10 +======= + --> $DIR/arithmetic_side_effects.rs:349:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:360:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:360:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = 1 - _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:361:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:361:10 +======= + --> $DIR/arithmetic_side_effects.rs:350:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:361:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:361:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = &1 - _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:362:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:362:10 +======= + --> $DIR/arithmetic_side_effects.rs:351:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:362:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:362:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n / 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:363:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:363:10 +======= + --> $DIR/arithmetic_side_effects.rs:352:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:363:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:363:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n / &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:364:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:364:10 +======= + --> $DIR/arithmetic_side_effects.rs:353:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:364:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:364:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n % 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:365:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:365:10 +======= + --> $DIR/arithmetic_side_effects.rs:354:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:365:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:365:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n % &0; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:366:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:366:10 +======= + --> $DIR/arithmetic_side_effects.rs:355:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:366:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:366:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n * 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:367:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:367:10 +======= + --> $DIR/arithmetic_side_effects.rs:356:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:367:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:367:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = _n * &2; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:368:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:368:10 +======= + --> $DIR/arithmetic_side_effects.rs:357:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:368:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:368:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = 2 * _n; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:369:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:369:10 +======= + --> $DIR/arithmetic_side_effects.rs:358:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:369:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:369:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = &2 * _n; | ^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:370:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:370:10 +======= + --> $DIR/arithmetic_side_effects.rs:359:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:370:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:370:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = 23 + &85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:371:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:371:10 +======= + --> $DIR/arithmetic_side_effects.rs:360:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:371:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:371:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = &23 + 85; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:372:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:372:10 +======= + --> $DIR/arithmetic_side_effects.rs:361:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:372:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:372:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = &23 + &85; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:373:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:373:15 +======= + --> $DIR/arithmetic_side_effects.rs:362:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:373:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:373:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:374:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:374:15 +======= + --> $DIR/arithmetic_side_effects.rs:363:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:374:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:374:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom + &_custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:375:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:375:15 +======= + --> $DIR/arithmetic_side_effects.rs:364:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:375:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:375:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = Custom + _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:376:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:376:15 +======= + --> $DIR/arithmetic_side_effects.rs:365:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:376:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:376:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom + _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:377:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:377:15 +======= + --> $DIR/arithmetic_side_effects.rs:366:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:377:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:377:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom - Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:378:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:378:15 +======= + --> $DIR/arithmetic_side_effects.rs:367:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:378:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:378:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom - &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:379:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:379:15 +======= + --> $DIR/arithmetic_side_effects.rs:368:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:379:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:379:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = Custom - _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:380:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:380:15 +======= + --> $DIR/arithmetic_side_effects.rs:369:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:380:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:380:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom - _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:381:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:381:15 +======= + --> $DIR/arithmetic_side_effects.rs:370:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:381:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:381:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom / Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:382:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:382:15 +======= + --> $DIR/arithmetic_side_effects.rs:371:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:382:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:382:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom / &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:383:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:383:15 +======= + --> $DIR/arithmetic_side_effects.rs:372:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:383:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:383:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom % Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:384:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:384:15 +======= + --> $DIR/arithmetic_side_effects.rs:373:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:384:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:384:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom % &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:385:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:385:15 +======= + --> $DIR/arithmetic_side_effects.rs:374:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:385:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:385:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom * Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:386:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:386:15 +======= + --> $DIR/arithmetic_side_effects.rs:375:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:386:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:386:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom * &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:387:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:387:15 +======= + --> $DIR/arithmetic_side_effects.rs:376:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:387:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:387:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = Custom * _custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:388:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:388:15 +======= + --> $DIR/arithmetic_side_effects.rs:377:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:388:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:388:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom * _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:389:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:389:15 +======= + --> $DIR/arithmetic_side_effects.rs:378:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:389:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:389:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = Custom + &Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:390:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:390:15 +======= + --> $DIR/arithmetic_side_effects.rs:379:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:390:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:390:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom + Custom; | ^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:391:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:391:15 +======= + --> $DIR/arithmetic_side_effects.rs:380:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:391:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:391:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom + &Custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:392:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:392:15 +======= + --> $DIR/arithmetic_side_effects.rs:381:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:392:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:392:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom >> _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:393:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:393:15 +======= + --> $DIR/arithmetic_side_effects.rs:382:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:393:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:393:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = _custom >> &_custom; | ^^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:394:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:394:15 +======= + --> $DIR/arithmetic_side_effects.rs:383:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:394:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:394:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = Custom << _custom; | ^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:395:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:395:15 +======= + --> $DIR/arithmetic_side_effects.rs:384:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:395:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:395:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = &Custom << _custom; | ^^^^^^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/arithmetic_side_effects.rs:398:23 | LL | _n.saturating_div(0); @@ -590,114 +2040,414 @@ LL | _n.wrapping_rem_euclid(_n); error: arithmetic operation that can potentially result in unexpected side-effects --> $DIR/arithmetic_side_effects.rs:409:10 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/arithmetic_side_effects.rs:387:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = -_n; | ^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:410:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:410:10 +======= + --> $DIR/arithmetic_side_effects.rs:388:10 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:410:10 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:410:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _n = -&_n; | ^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:411:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:411:15 +======= + --> $DIR/arithmetic_side_effects.rs:389:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:411:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:411:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = -_custom; | ^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:412:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:412:15 +======= + --> $DIR/arithmetic_side_effects.rs:390:15 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:412:15 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:412:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _custom = -&_custom; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:421:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:421:5 +======= + --> $DIR/arithmetic_side_effects.rs:399:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:421:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:421:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1 + i; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:422:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:422:5 +======= + --> $DIR/arithmetic_side_effects.rs:400:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:422:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:422:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i * 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:423:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:423:5 +======= + --> $DIR/arithmetic_side_effects.rs:401:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:423:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:423:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1 % i / 2; | ^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:424:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:424:5 +======= + --> $DIR/arithmetic_side_effects.rs:402:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:424:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:424:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i - 2 + 2 - i; | ^^^^^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:425:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:425:5 +======= + --> $DIR/arithmetic_side_effects.rs:403:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:425:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:425:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | -i; | ^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:436:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:436:5 +======= + --> $DIR/arithmetic_side_effects.rs:414:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:436:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:436:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i += 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:437:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:437:5 +======= + --> $DIR/arithmetic_side_effects.rs:415:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:437:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:437:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i -= 1; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:438:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:438:5 +======= + --> $DIR/arithmetic_side_effects.rs:416:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:438:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:438:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i *= 2; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:440:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:440:5 +======= + --> $DIR/arithmetic_side_effects.rs:418:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:440:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:440:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i /= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:442:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:442:5 +======= + --> $DIR/arithmetic_side_effects.rs:420:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:442:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:442:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i /= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:443:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:443:5 +======= + --> $DIR/arithmetic_side_effects.rs:421:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:443:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:443:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i /= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:445:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:445:5 +======= + --> $DIR/arithmetic_side_effects.rs:423:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= --> $DIR/arithmetic_side_effects.rs:445:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:445:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i %= 0; | ^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:447:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:447:5 +======= + --> $DIR/arithmetic_side_effects.rs:425:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:447:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:447:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i %= var1; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:448:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/arithmetic_side_effects.rs:448:5 +======= + --> $DIR/arithmetic_side_effects.rs:426:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:448:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/arithmetic_side_effects.rs:448:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | i %= var2; | ^^^^^^^^^ error: arithmetic operation that can potentially result in unexpected side-effects +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:458:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/arithmetic_side_effects.rs:458:5 +======= + --> $DIR/arithmetic_side_effects.rs:436:5 +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= + --> $DIR/arithmetic_side_effects.rs:458:5 +>>>>>>> 3db7352b8 ([arithmetic_side_effects] Fix #10590) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/arithmetic_side_effects.rs:458:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 10 / a | ^^^^^^ diff --git a/tests/ui/blocks_in_if_conditions_closure.rs b/tests/ui/blocks_in_if_conditions_closure.rs index d6d085d7fd14..05b10d3e6719 100644 --- a/tests/ui/blocks_in_if_conditions_closure.rs +++ b/tests/ui/blocks_in_if_conditions_closure.rs @@ -1,10 +1,32 @@ #![warn(clippy::blocks_in_if_conditions)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( unused, clippy::let_and_return, clippy::needless_if, clippy::unnecessary_literal_unwrap )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(unused, clippy::let_and_return, clippy::needless_if)] +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn predicate bool, T>(pfn: F, val: T) -> bool { pfn(val) diff --git a/tests/ui/box_default.fixed b/tests/ui/box_default.fixed index 840902b5323e..01a8f349defc 100644 --- a/tests/ui/box_default.fixed +++ b/tests/ui/box_default.fixed @@ -1,6 +1,14 @@ //@run-rustfix #![warn(clippy::box_default)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::default_constructed_unit_structs)] +======= +#![allow(unused, clippy::default_constructed_unit_structs)] +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::default_constructed_unit_structs)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Default)] struct ImplementsDefault; diff --git a/tests/ui/box_default.rs b/tests/ui/box_default.rs index 3618486a4732..572fdd2024b8 100644 --- a/tests/ui/box_default.rs +++ b/tests/ui/box_default.rs @@ -1,6 +1,14 @@ //@run-rustfix #![warn(clippy::box_default)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::default_constructed_unit_structs)] +======= +#![allow(unused, clippy::default_constructed_unit_structs)] +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::default_constructed_unit_structs)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Default)] struct ImplementsDefault; diff --git a/tests/ui/cast.stderr b/tests/ui/cast.stderr index de29af78ef30..ab17e9a7404a 100644 --- a/tests/ui/cast.stderr +++ b/tests/ui/cast.stderr @@ -244,9 +244,30 @@ error: casting `usize` to `i16` may wrap around the value on targets with 16-bit | LL | 1usize as i16; // wraps on 16 bit ptr size | ^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD | = note: `usize` and `isize` may be as small as 16 bits on some platforms = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +======= +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +======= +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +======= + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +>>>>>>> 615b25c20 (Rebase attempt number 2) error: casting `usize` to `i32` may truncate the value on targets with 64-bit wide pointers --> $DIR/cast.rs:46:5 @@ -277,9 +298,30 @@ error: casting `u16` to `isize` may wrap around the value on targets with 16-bit | LL | 1u16 as isize; // wraps on 16 bit ptr size | ^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +======= +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +======= +>>>>>>> 6681914b5 (make cast_possible_wrap not lint on conversions for sizes that cannot wrap, and make it work correctly for 16 bit {u,i}size) +======= + | + = note: `usize` and `isize` may be as small as 16 bits on some platforms + = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +>>>>>>> 7cd0ec58a (add more info link) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= | = note: `usize` and `isize` may be as small as 16 bits on some platforms = note: for more information see https://doc.rust-lang.org/reference/types/numeric.html#machine-dependent-integer-types +>>>>>>> 615b25c20 (Rebase attempt number 2) error: casting `u32` to `isize` may wrap around the value on targets with 32-bit wide pointers --> $DIR/cast.rs:50:5 diff --git a/tests/ui/clone_on_copy_impl.rs b/tests/ui/clone_on_copy_impl.rs index b7c186bef772..552011361c14 100644 --- a/tests/ui/clone_on_copy_impl.rs +++ b/tests/ui/clone_on_copy_impl.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::incorrect_clone_impl_on_copy_type)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::incorrect_clone_impl_on_copy_type)] +======= +#![allow(clippy::needless_clone_impl)] +>>>>>>> 67d5e6ec3 (add lint [`needless_clone_impl`]) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type)] +>>>>>>> 10cc1684c (rename lint and disallow `clone_from`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type)] +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::fmt; use std::marker::PhantomData; diff --git a/tests/ui/collapsible_if.fixed b/tests/ui/collapsible_if.fixed index e305e1d7a871..065b9410a3c9 100644 --- a/tests/ui/collapsible_if.fixed +++ b/tests/ui/collapsible_if.fixed @@ -2,7 +2,22 @@ #![allow( clippy::assertions_on_constants, clippy::equatable_if_let, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_if, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_if, +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + clippy::needless_if, +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_if, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::nonminimal_bool, clippy::eq_op )] diff --git a/tests/ui/collapsible_if.rs b/tests/ui/collapsible_if.rs index 7c52959d3b51..fc682bf2b8e2 100644 --- a/tests/ui/collapsible_if.rs +++ b/tests/ui/collapsible_if.rs @@ -2,7 +2,22 @@ #![allow( clippy::assertions_on_constants, clippy::equatable_if_let, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_if, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_if, +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + clippy::needless_if, +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_if, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::nonminimal_bool, clippy::eq_op )] diff --git a/tests/ui/collapsible_if.stderr b/tests/ui/collapsible_if.stderr index 4a1a9e8a60ae..9f3f7db9f54e 100644 --- a/tests/ui/collapsible_if.stderr +++ b/tests/ui/collapsible_if.stderr @@ -1,5 +1,21 @@ error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/collapsible_if.rs:15:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:15:5 +======= + --> $DIR/collapsible_if.rs:14:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:15:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:15:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" { LL | | if y == "world" { @@ -17,7 +33,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:21:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/collapsible_if.rs:21:5 +======= + --> $DIR/collapsible_if.rs:20:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:21:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:21:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" || x == "world" { LL | | if y == "world" || y == "hello" { @@ -34,7 +66,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:27:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/collapsible_if.rs:27:5 +======= + --> $DIR/collapsible_if.rs:26:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:27:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:27:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" && x == "world" { LL | | if y == "world" || y == "hello" { @@ -51,7 +99,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:33:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:33:5 +======= + --> $DIR/collapsible_if.rs:32:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= --> $DIR/collapsible_if.rs:33:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:33:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" || x == "world" { LL | | if y == "world" && y == "hello" { @@ -68,7 +132,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:39:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:39:5 +======= + --> $DIR/collapsible_if.rs:38:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= --> $DIR/collapsible_if.rs:39:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:39:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" && x == "world" { LL | | if y == "world" && y == "hello" { @@ -85,7 +165,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:45:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:45:5 +======= + --> $DIR/collapsible_if.rs:44:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:45:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/collapsible_if.rs:45:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if 42 == 1337 { LL | | if 'a' != 'A' { @@ -102,7 +198,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:101:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:101:5 +======= + --> $DIR/collapsible_if.rs:100:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:101:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/collapsible_if.rs:101:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if x == "hello" { LL | | if y == "world" { // Collapsible @@ -119,7 +231,23 @@ LL + } | error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/collapsible_if.rs:160:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:160:5 +======= + --> $DIR/collapsible_if.rs:159:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:160:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/collapsible_if.rs:160:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if matches!(true, true) { LL | | if matches!(true, true) {} @@ -127,7 +255,23 @@ LL | | } | |_____^ help: collapse nested if block: `if matches!(true, true) && matches!(true, true) {}` error: this `if` statement can be collapsed +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:165:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/collapsible_if.rs:165:5 +======= + --> $DIR/collapsible_if.rs:164:5 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/collapsible_if.rs:165:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/collapsible_if.rs:165:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / if matches!(true, true) && truth() { LL | | if matches!(true, true) {} diff --git a/tests/ui/dbg_macro.rs b/tests/ui/dbg_macro.rs index 6c63c098916b..0020052f0d51 100644 --- a/tests/ui/dbg_macro.rs +++ b/tests/ui/dbg_macro.rs @@ -22,6 +22,16 @@ fn main() { } fn issue9914() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! foo { ($x:expr) => { $x; @@ -38,13 +48,45 @@ fn issue9914() { }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) dbg!(); #[allow(clippy::let_unit_value)] let _ = dbg!(); bar(dbg!()); +<<<<<<< HEAD +<<<<<<< HEAD foo!(dbg!()); foo2!(foo!(dbg!())); expand_to_dbg!(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + foo!(dbg!()); + foo2!(foo!(dbg!())); + expand_to_dbg!(); +======= +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + foo!(dbg!()); + foo2!(foo!(dbg!())); + expand_to_dbg!(); +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + foo!(dbg!()); + foo2!(foo!(dbg!())); + expand_to_dbg!(); +>>>>>>> 615b25c20 (Rebase attempt number 2) } mod issue7274 { diff --git a/tests/ui/dbg_macro.stderr b/tests/ui/dbg_macro.stderr index 3d2926259590..a0d30a5cf8c7 100644 --- a/tests/ui/dbg_macro.stderr +++ b/tests/ui/dbg_macro.stderr @@ -99,7 +99,27 @@ LL | (1, 2, 3, 4, 5); | ~~~~~~~~~~~~~~~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/dbg_macro.rs:41:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:41:5 +======= + --> $DIR/dbg_macro.rs:26:5 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:42:5 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:41:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:41:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dbg!(); | ^^^^^^^ @@ -111,7 +131,27 @@ LL + | error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:43:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/dbg_macro.rs:43:13 +======= + --> $DIR/dbg_macro.rs:28:13 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:44:13 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:43:13 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:43:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = dbg!(); | ^^^^^^ @@ -122,7 +162,27 @@ LL | let _ = (); | ~~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:44:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:44:9 +======= + --> $DIR/dbg_macro.rs:29:9 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:45:9 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= --> $DIR/dbg_macro.rs:44:9 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:44:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | bar(dbg!()); | ^^^^^^ @@ -133,7 +193,24 @@ LL | bar(()); | ~~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:45:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:45:10 +======= + --> $DIR/dbg_macro.rs:46:10 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:45:10 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/dbg_macro.rs:45:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | foo!(dbg!()); | ^^^^^^ @@ -144,7 +221,23 @@ LL | foo!(()); | ~~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:46:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:46:16 +======= + --> $DIR/dbg_macro.rs:47:16 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:46:16 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/dbg_macro.rs:46:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | foo2!(foo!(dbg!())); | ^^^^^^ @@ -155,7 +248,26 @@ LL | foo2!(foo!(())); | ~~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/dbg_macro.rs:67:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:67:9 +======= + --> $DIR/dbg_macro.rs:49:9 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:68:9 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:67:9 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:67:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dbg!(2); | ^^^^^^^ @@ -166,7 +278,27 @@ LL | 2; | ~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:73:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/dbg_macro.rs:73:5 +======= + --> $DIR/dbg_macro.rs:55:5 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:74:5 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:73:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:73:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dbg!(1); | ^^^^^^^ @@ -177,7 +309,27 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:78:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:78:5 +======= + --> $DIR/dbg_macro.rs:60:5 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:79:5 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= --> $DIR/dbg_macro.rs:78:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/dbg_macro.rs:78:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dbg!(1); | ^^^^^^^ @@ -188,7 +340,27 @@ LL | 1; | ~ error: the `dbg!` macro is intended as a debugging tool +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:84:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/dbg_macro.rs:84:9 +======= + --> $DIR/dbg_macro.rs:66:9 +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= + --> $DIR/dbg_macro.rs:85:9 +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +======= + --> $DIR/dbg_macro.rs:84:9 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/dbg_macro.rs:84:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dbg!(1); | ^^^^^^^ @@ -198,5 +370,21 @@ help: remove the invocation before committing it to a version control system LL | 1; | ~ +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 18 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 18 previous errors +======= +error: aborting due to 16 previous errors +>>>>>>> cc607fe32 (don't remove `dbg!` in arbitrary expressions) +======= +error: aborting due to 18 previous errors +>>>>>>> f0be0ee1a (handle nested macros and add tests for them) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 18 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/default_constructed_unit_structs.fixed b/tests/ui/default_constructed_unit_structs.fixed index ac5fe38ff443..f22ca12d54e0 100644 --- a/tests/ui/default_constructed_unit_structs.fixed +++ b/tests/ui/default_constructed_unit_structs.fixed @@ -127,7 +127,22 @@ fn main() { // should lint let _ = PhantomData::; let _: PhantomData = PhantomData; +<<<<<<< HEAD +<<<<<<< HEAD let _: PhantomData = std::marker::PhantomData; +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _: PhantomData = std::marker::PhantomData; +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= + let _: PhantomData = std::marker::PhantomData; +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let _: PhantomData = std::marker::PhantomData; +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = UnitStruct; // should not lint @@ -139,6 +154,16 @@ fn main() { let _ = EmptyStruct::default(); let _ = FakeDefault::default(); let _ = ::default(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! in_macro { ($i:ident) => {{ @@ -156,4 +181,15 @@ fn main() { } let _ = ::default(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/default_constructed_unit_structs.rs b/tests/ui/default_constructed_unit_structs.rs index de7f14ffbd95..151e3f486f9a 100644 --- a/tests/ui/default_constructed_unit_structs.rs +++ b/tests/ui/default_constructed_unit_structs.rs @@ -127,7 +127,22 @@ fn main() { // should lint let _ = PhantomData::::default(); let _: PhantomData = PhantomData::default(); +<<<<<<< HEAD +<<<<<<< HEAD let _: PhantomData = std::marker::PhantomData::default(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _: PhantomData = std::marker::PhantomData::default(); +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= + let _: PhantomData = std::marker::PhantomData::default(); +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let _: PhantomData = std::marker::PhantomData::default(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = UnitStruct::default(); // should not lint @@ -139,6 +154,16 @@ fn main() { let _ = EmptyStruct::default(); let _ = FakeDefault::default(); let _ = ::default(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! in_macro { ($i:ident) => {{ @@ -156,4 +181,15 @@ fn main() { } let _ = ::default(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/default_constructed_unit_structs.stderr b/tests/ui/default_constructed_unit_structs.stderr index 13abb9149da2..25b45d94d012 100644 --- a/tests/ui/default_constructed_unit_structs.stderr +++ b/tests/ui/default_constructed_unit_structs.stderr @@ -25,16 +25,74 @@ LL | let _: PhantomData = PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/default_constructed_unit_structs.rs:130:55 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) + --> $DIR/default_constructed_unit_structs.rs:108:55 +======= + --> $DIR/default_constructed_unit_structs.rs:130:55 +>>>>>>> e6dc0efc0 (Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup) +======= + --> $DIR/default_constructed_unit_structs.rs:130:55 +>>>>>>> 8c82486ea ([`default_constructed_unit_structs`]: do not lint type aliases) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/default_constructed_unit_structs.rs:130:55 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: PhantomData = std::marker::PhantomData::default(); | ^^^^^^^^^^^ help: remove this call to `default` error: use of `default` to create a unit struct +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/default_constructed_unit_structs.rs:131:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/default_constructed_unit_structs.rs:109:23 +<<<<<<< HEAD +======= + --> $DIR/default_constructed_unit_structs.rs:108:23 +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +======= + --> $DIR/default_constructed_unit_structs.rs:131:23 +>>>>>>> e6dc0efc0 (Merge commit '30448e8cf98d4754350db0c959644564f317bc0f' into clippyup) +======= --> $DIR/default_constructed_unit_structs.rs:131:23 +>>>>>>> 8c82486ea ([`default_constructed_unit_structs`]: do not lint type aliases) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/default_constructed_unit_structs.rs:131:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = UnitStruct::default(); | ^^^^^^^^^^^ help: remove this call to `default` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 6 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 6 previous errors +======= +error: aborting due to 5 previous errors +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +error: aborting due to 6 previous errors +>>>>>>> b76b0aeb6 (Merge commit '435a8ad86c7a33bd7ffb91c59039943408d3b6aa' into clippyup) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 6 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/derive.rs b/tests/ui/derive.rs index ff4dcbfa2f2d..530b215c3411 100644 --- a/tests/ui/derive.rs +++ b/tests/ui/derive.rs @@ -1,8 +1,32 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::incorrect_clone_impl_on_copy_type, dead_code)] +======= +#![allow(clippy::needless_clone_impl, dead_code)] +>>>>>>> 67d5e6ec3 (add lint [`needless_clone_impl`]) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type, dead_code)] +>>>>>>> 10cc1684c (rename lint and disallow `clone_from`) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::incorrect_clone_impl_on_copy_type, clippy::incorrect_partial_ord_impl_on_ord_type, dead_code )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 844afbfeb (use `other` instead of `self`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::expl_impl_clone_on_copy)] #[derive(Copy)] diff --git a/tests/ui/diverging_sub_expression.rs b/tests/ui/diverging_sub_expression.rs index 9b1619baf0e6..2ba67ef3a72d 100644 --- a/tests/ui/diverging_sub_expression.rs +++ b/tests/ui/diverging_sub_expression.rs @@ -40,6 +40,16 @@ fn foobar() { // lint blocks as well 15 => true || { return; }, 16 => false || { return; }, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 0c545c7bc (also lint single expression blocks) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // ... and when it's a single expression 17 => true || { return }, 18 => false || { return }, @@ -49,8 +59,28 @@ fn foobar() { // ... or multiple statements 21 => true || { _ = 1; return; }, 22 => false || { _ = 1; return; }, +<<<<<<< HEAD +<<<<<<< HEAD 23 => true || { return; true }, 24 => true || { return; true }, +======= +<<<<<<< HEAD +<<<<<<< HEAD + 23 => true || { return; true }, + 24 => true || { return; true }, +======= +>>>>>>> f4b02aa37 (fix #10776) +======= +>>>>>>> 0c545c7bc (also lint single expression blocks) +======= + 23 => true || { return; true }, + 24 => true || { return; true }, +>>>>>>> 35aff1ae8 (refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + 23 => true || { return; true }, + 24 => true || { return; true }, +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => true || break, }; } diff --git a/tests/ui/diverging_sub_expression.stderr b/tests/ui/diverging_sub_expression.stderr index 243a5cf5369a..36e64793abdf 100644 --- a/tests/ui/diverging_sub_expression.stderr +++ b/tests/ui/diverging_sub_expression.stderr @@ -63,10 +63,49 @@ LL | 18 => false || { return }, | ^^^^^^ error: sub-expression diverges +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/diverging_sub_expression.rs:54:26 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/diverging_sub_expression.rs:54:26 +======= + --> $DIR/diverging_sub_expression.rs:47:36 + | +LL | 19 => true || { _ = 1; return }, + | ^^^^^^ + +error: sub-expression diverges + --> $DIR/diverging_sub_expression.rs:48:37 + | +LL | 20 => false || { _ = 1; return }, + | ^^^^^^ + +error: sub-expression diverges +======= +>>>>>>> c1c134a28 (ensure there are no stmts for expr check) + --> $DIR/diverging_sub_expression.rs:52:26 +>>>>>>> 0c545c7bc (also lint single expression blocks) +======= + --> $DIR/diverging_sub_expression.rs:54:26 +>>>>>>> 35aff1ae8 (refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/diverging_sub_expression.rs:54:26 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | _ => true || break, | ^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: aborting due to 11 previous errors diff --git a/tests/ui/doc/needless_doctest_main.rs b/tests/ui/doc/needless_doctest_main.rs index f1a2c0575ee5..5f3eec0e5be9 100644 --- a/tests/ui/doc/needless_doctest_main.rs +++ b/tests/ui/doc/needless_doctest_main.rs @@ -8,6 +8,19 @@ //! m.insert(1u32, 2u32); //! } //! ``` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +//! +>>>>>>> 062b20990 (Ignore `main()` in `no_test` code fences) +======= +>>>>>>> a5d05f2f9 (run `cargo dev fmt`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) /// some description here /// ```rust,no_test @@ -16,5 +29,23 @@ /// } /// ``` fn foo() {} +<<<<<<< HEAD +<<<<<<< HEAD + +fn main() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + +fn main() {} +======= +>>>>>>> 062b20990 (Ignore `main()` in `no_test` code fences) +======= + +fn main() {} +>>>>>>> 867bd1538 (add main function to test itself) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= fn main() {} +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/drain_collect.fixed b/tests/ui/drain_collect.fixed index 11001bd319f3..7ea6d21a7810 100644 --- a/tests/ui/drain_collect.fixed +++ b/tests/ui/drain_collect.fixed @@ -70,8 +70,29 @@ fn string_dont_lint(b: &mut String) -> HashSet { b.drain(..).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn not_whole_length(v: &mut Vec) -> Vec { v.drain(1..).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +======= +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/drain_collect.rs b/tests/ui/drain_collect.rs index 373a3ca3506d..327b92adeb2f 100644 --- a/tests/ui/drain_collect.rs +++ b/tests/ui/drain_collect.rs @@ -1,7 +1,29 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@run-rustfix #![deny(clippy::drain_collect)] #![allow(dead_code)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![deny(clippy::drain_collect)] +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::collections::{BinaryHeap, HashMap, HashSet, VecDeque}; @@ -53,11 +75,32 @@ fn vec4(b: &mut Vec) -> Vec { b.drain(0..b.len()).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn vec_no_reborrow() -> Vec { let mut b = vec![1, 2, 3]; b.drain(..).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn vec_dont_lint(b: &mut Vec) -> HashSet { b.drain(..).collect() } @@ -70,8 +113,29 @@ fn string_dont_lint(b: &mut String) -> HashSet { b.drain(..).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn not_whole_length(v: &mut Vec) -> Vec { v.drain(1..).collect() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= +>>>>>>> 5821fbbc3 (add test case for not whole length, move sugg into variable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/drain_collect.stderr b/tests/ui/drain_collect.stderr index 0792f0254cb5..0f949f0d2172 100644 --- a/tests/ui/drain_collect.stderr +++ b/tests/ui/drain_collect.stderr @@ -1,4 +1,12 @@ error: you seem to be trying to move all elements into a new `BinaryHeap` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/drain_collect.rs:9:5 | LL | b.drain().collect() @@ -6,12 +14,91 @@ LL | b.drain().collect() | note: the lint level is defined here --> $DIR/drain_collect.rs:3:9 +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/drain_collect.rs:6:5 +======= + --> $DIR/drain_collect.rs:9:5 +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) + | +LL | b.drain().collect() + | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + | +note: the lint level is defined here +<<<<<<< HEAD + --> $DIR/drain_collect.rs:1:9 +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= + --> $DIR/drain_collect.rs:3:9 +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![deny(clippy::drain_collect)] | ^^^^^^^^^^^^^^^^^^^^^ error: you seem to be trying to move all elements into a new `HashMap` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + --> $DIR/drain_collect.rs:17:5 + | +LL | b.drain().collect() + | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `HashSet` + --> $DIR/drain_collect.rs:25:5 + | +LL | b.drain().collect() + | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` + --> $DIR/drain_collect.rs:33:5 + | +LL | b.drain(..).collect() + | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` + --> $DIR/drain_collect.rs:41:5 + | +LL | b.drain(..).collect() + | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` + --> $DIR/drain_collect.rs:45:5 + | +LL | b.drain(0..).collect() + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` + --> $DIR/drain_collect.rs:49:5 + | +LL | b.drain(..b.len()).collect() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` + --> $DIR/drain_collect.rs:53:5 + | +LL | b.drain(0..b.len()).collect() + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` + +error: you seem to be trying to move all elements into a new `Vec` +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/drain_collect.rs:14:5 +======= --> $DIR/drain_collect.rs:17:5 +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) | LL | b.drain().collect() | ^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` @@ -52,12 +139,30 @@ error: you seem to be trying to move all elements into a new `Vec` LL | b.drain(0..b.len()).collect() | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` +<<<<<<< HEAD +error: you seem to be trying to move all elements into a new `String` +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= error: you seem to be trying to move all elements into a new `Vec` +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/drain_collect.rs:58:5 | LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(&mut b)` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: you seem to be trying to move all elements into a new `String` --> $DIR/drain_collect.rs:66:5 | @@ -65,4 +170,16 @@ LL | b.drain(..).collect() | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `mem::take`: `std::mem::take(b)` error: aborting due to 10 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 9 previous errors +>>>>>>> 2748ab956 (new lint: `drain_collect`) +======= +>>>>>>> d2a6ec2d4 (take into account reborrowing when inserting `&mut` in sugg) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/empty_line_after_doc_comments.rs b/tests/ui/empty_line_after_doc_comments.rs index 83db2a07d334..187b839a8c3d 100644 --- a/tests/ui/empty_line_after_doc_comments.rs +++ b/tests/ui/empty_line_after_doc_comments.rs @@ -1,4 +1,16 @@ //@aux-build:proc_macro_attr.rs:proc-macro +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +// Flaky test, see /~https://github.com/rust-lang/rust/issues/113585. +//@ignore-32bit +//@ignore-64bit +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::empty_line_after_doc_comments)] #![allow(clippy::assertions_on_constants)] #![feature(custom_inner_attributes)] diff --git a/tests/ui/empty_line_after_outer_attribute.rs b/tests/ui/empty_line_after_outer_attribute.rs index b2d7ddae4274..fb564c584e30 100644 --- a/tests/ui/empty_line_after_outer_attribute.rs +++ b/tests/ui/empty_line_after_outer_attribute.rs @@ -1,4 +1,16 @@ //@aux-build:proc_macro_attr.rs:proc-macro +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +// Flaky test, see /~https://github.com/rust-lang/rust/issues/113585. +//@ignore-32bit +//@ignore-64bit +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::empty_line_after_outer_attr)] #![allow(clippy::assertions_on_constants)] #![feature(custom_inner_attributes)] diff --git a/tests/ui/endian_bytes.rs b/tests/ui/endian_bytes.rs index 6bf014fc8095..f5a738fe1f34 100644 --- a/tests/ui/endian_bytes.rs +++ b/tests/ui/endian_bytes.rs @@ -2,6 +2,16 @@ #![allow(clippy::diverging_sub_expression)] #![no_main] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! fn_body { () => { 2u8.to_ne_bytes(); @@ -65,7 +75,23 @@ macro_rules! fn_body { } // bless breaks if I use fn_body too much (oops) +<<<<<<< HEAD +<<<<<<< HEAD macro_rules! fn_body_smol { +======= +<<<<<<< HEAD +<<<<<<< HEAD +macro_rules! fn_body_smol { +======= +macro_rules! fn_body_small { +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= +macro_rules! fn_body_smol { +>>>>>>> 04b7cae37 (refine output) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +macro_rules! fn_body_smol { +>>>>>>> 615b25c20 (Rebase attempt number 2) () => { 2u8.to_ne_bytes(); u8::from_ne_bytes(todo!()); @@ -78,8 +104,67 @@ macro_rules! fn_body_smol { }; } +#[rustfmt::skip] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +#[warn(clippy::host_endian_bytes)] +fn host() { fn_body!(); } + +#[rustfmt::skip] +#[warn(clippy::little_endian_bytes)] +fn little() { fn_body!(); } + +#[rustfmt::skip] +#[warn(clippy::big_endian_bytes)] +fn big() { fn_body!(); } + +#[rustfmt::skip] +#[warn(clippy::host_endian_bytes)] +#[warn(clippy::big_endian_bytes)] +fn host_encourage_little() { fn_body_smol!(); } + +#[rustfmt::skip] +#[warn(clippy::host_endian_bytes)] +#[warn(clippy::little_endian_bytes)] +fn host_encourage_big() { fn_body_smol!(); } + #[rustfmt::skip] #[warn(clippy::host_endian_bytes)] +#[warn(clippy::little_endian_bytes)] +#[warn(clippy::big_endian_bytes)] +fn no_help() { fn_body_smol!(); } + +#[rustfmt::skip] +#[warn(clippy::little_endian_bytes)] +#[warn(clippy::big_endian_bytes)] +fn little_encourage_host() { fn_body_smol!(); } + +#[rustfmt::skip] +#[warn(clippy::host_endian_bytes)] +#[warn(clippy::little_endian_bytes)] +fn little_encourage_big() { fn_body_smol!(); } + +#[rustfmt::skip] +#[warn(clippy::big_endian_bytes)] +#[warn(clippy::little_endian_bytes)] +fn big_encourage_host() { fn_body_smol!(); } + +#[rustfmt::skip] +#[warn(clippy::host_endian_bytes)] +#[warn(clippy::big_endian_bytes)] +fn big_encourage_little() { fn_body_smol!(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +#[warn(clippy::host_endian_bytes)] fn host() { fn_body!(); } #[rustfmt::skip] @@ -119,9 +204,54 @@ fn little_encourage_big() { fn_body_smol!(); } #[rustfmt::skip] #[warn(clippy::big_endian_bytes)] #[warn(clippy::little_endian_bytes)] +<<<<<<< HEAD +<<<<<<< HEAD +fn big_no_help() { + 2u8.to_be_bytes(); + 2i8.to_be_bytes(); + 2u16.to_be_bytes(); + 2i16.to_be_bytes(); + 2u32.to_be_bytes(); + 2i32.to_be_bytes(); + 2u64.to_be_bytes(); + 2i64.to_be_bytes(); + 2u128.to_be_bytes(); + 2i128.to_be_bytes(); + 2usize.to_be_bytes(); + 2isize.to_be_bytes(); + 2.0f32.to_be_bytes(); + 2.0f64.to_be_bytes(); + u8::from_be_bytes(todo!()); + i8::from_be_bytes(todo!()); + u16::from_be_bytes(todo!()); + i16::from_be_bytes(todo!()); + u32::from_be_bytes(todo!()); + i32::from_be_bytes(todo!()); + u64::from_be_bytes(todo!()); + i64::from_be_bytes(todo!()); + u128::from_be_bytes(todo!()); + i128::from_be_bytes(todo!()); + usize::from_be_bytes(todo!()); + isize::from_be_bytes(todo!()); + f32::from_be_bytes(todo!()); + f64::from_be_bytes(todo!()); +} +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= +fn big_encourage_host() { fn_body_small!(); } +======= fn big_encourage_host() { fn_body_smol!(); } +>>>>>>> 04b7cae37 (refine output) #[rustfmt::skip] #[warn(clippy::host_endian_bytes)] #[warn(clippy::big_endian_bytes)] +<<<<<<< HEAD +fn big_encourage_little() { fn_body_small!(); } +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +======= fn big_encourage_little() { fn_body_smol!(); } +>>>>>>> 04b7cae37 (refine output) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/endian_bytes.stderr b/tests/ui/endian_bytes.stderr index 5e64ea5b5ab8..10d8138b9350 100644 --- a/tests/ui/endian_bytes.stderr +++ b/tests/ui/endian_bytes.stderr @@ -1,3 +1,12 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: usage of the `u8::to_ne_bytes` method --> $DIR/endian_bytes.rs:7:9 | @@ -1028,4 +1037,1301 @@ LL | fn big_encourage_little() { fn_body_smol!(); } = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 86 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: use of the method `from_ne_bytes` + --> $DIR/endian_bytes.rs:6:11 +======= +error: usage of the method `to_ne_bytes` +======= +error: usage of the `u8::to_ne_bytes` method +>>>>>>> 04b7cae37 (refine output) + --> $DIR/endian_bytes.rs:7:9 +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: `-D clippy::host-endian-bytes` implied by `-D warnings` + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:8:9 + | +LL | 2i8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u16::to_ne_bytes` method + --> $DIR/endian_bytes.rs:9:9 + | +LL | 2u16.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i16::to_ne_bytes` method + --> $DIR/endian_bytes.rs:10:9 + | +LL | 2i16.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u32::to_ne_bytes` method + --> $DIR/endian_bytes.rs:11:9 + | +LL | 2u32.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i32::to_ne_bytes` method + --> $DIR/endian_bytes.rs:12:9 + | +LL | 2i32.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u64::to_ne_bytes` method + --> $DIR/endian_bytes.rs:13:9 + | +LL | 2u64.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i64::to_ne_bytes` method + --> $DIR/endian_bytes.rs:14:9 + | +LL | 2i64.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u128::to_ne_bytes` method + --> $DIR/endian_bytes.rs:15:9 + | +LL | 2u128.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i128::to_ne_bytes` method + --> $DIR/endian_bytes.rs:16:9 + | +LL | 2i128.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `f32::to_ne_bytes` method + --> $DIR/endian_bytes.rs:17:9 + | +LL | 2.0f32.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `f64::to_ne_bytes` method + --> $DIR/endian_bytes.rs:18:9 + | +LL | 2.0f64.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `usize::to_ne_bytes` method + --> $DIR/endian_bytes.rs:19:9 + | +LL | 2usize.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `isize::to_ne_bytes` method + --> $DIR/endian_bytes.rs:20:9 + | +LL | 2isize.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:21:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i8::from_ne_bytes` + --> $DIR/endian_bytes.rs:22:9 + | +LL | i8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u16::from_ne_bytes` + --> $DIR/endian_bytes.rs:23:9 + | +LL | u16::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i16::from_ne_bytes` + --> $DIR/endian_bytes.rs:24:9 + | +LL | i16::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u32::from_ne_bytes` + --> $DIR/endian_bytes.rs:25:9 + | +LL | u32::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i32::from_ne_bytes` + --> $DIR/endian_bytes.rs:26:9 + | +LL | i32::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u64::from_ne_bytes` + --> $DIR/endian_bytes.rs:27:9 + | +LL | u64::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i64::from_ne_bytes` + --> $DIR/endian_bytes.rs:28:9 + | +LL | i64::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u128::from_ne_bytes` + --> $DIR/endian_bytes.rs:29:9 + | +LL | u128::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i128::from_ne_bytes` + --> $DIR/endian_bytes.rs:30:9 + | +LL | i128::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `usize::from_ne_bytes` + --> $DIR/endian_bytes.rs:31:9 + | +LL | usize::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `isize::from_ne_bytes` + --> $DIR/endian_bytes.rs:32:9 + | +LL | isize::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `f32::from_ne_bytes` + --> $DIR/endian_bytes.rs:33:9 + | +LL | f32::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `f64::from_ne_bytes` + --> $DIR/endian_bytes.rs:34:9 + | +LL | f64::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host() { fn_body!(); } + | ---------- in this macro invocation + | + = help: specify the desired endianness explicitly + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:36:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: `-D clippy::little-endian-bytes` implied by `-D warnings` + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i8::to_le_bytes` method + --> $DIR/endian_bytes.rs:37:9 + | +LL | 2i8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u16::to_le_bytes` method + --> $DIR/endian_bytes.rs:38:9 + | +LL | 2u16.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i16::to_le_bytes` method + --> $DIR/endian_bytes.rs:39:9 + | +LL | 2i16.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u32::to_le_bytes` method + --> $DIR/endian_bytes.rs:40:9 + | +LL | 2u32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i32::to_le_bytes` method + --> $DIR/endian_bytes.rs:41:9 + | +LL | 2i32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u64::to_le_bytes` method + --> $DIR/endian_bytes.rs:42:9 + | +LL | 2u64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i64::to_le_bytes` method + --> $DIR/endian_bytes.rs:43:9 + | +LL | 2i64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u128::to_le_bytes` method + --> $DIR/endian_bytes.rs:44:9 + | +LL | 2u128.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `i128::to_le_bytes` method + --> $DIR/endian_bytes.rs:45:9 + | +LL | 2i128.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `f32::to_le_bytes` method + --> $DIR/endian_bytes.rs:46:9 + | +LL | 2.0f32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `f64::to_le_bytes` method + --> $DIR/endian_bytes.rs:47:9 + | +LL | 2.0f64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `usize::to_le_bytes` method + --> $DIR/endian_bytes.rs:48:9 + | +LL | 2usize.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `isize::to_le_bytes` method + --> $DIR/endian_bytes.rs:49:9 + | +LL | 2isize.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:50:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i8::from_le_bytes` + --> $DIR/endian_bytes.rs:51:9 + | +LL | i8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u16::from_le_bytes` + --> $DIR/endian_bytes.rs:52:9 + | +LL | u16::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i16::from_le_bytes` + --> $DIR/endian_bytes.rs:53:9 + | +LL | i16::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u32::from_le_bytes` + --> $DIR/endian_bytes.rs:54:9 + | +LL | u32::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i32::from_le_bytes` + --> $DIR/endian_bytes.rs:55:9 + | +LL | i32::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u64::from_le_bytes` + --> $DIR/endian_bytes.rs:56:9 + | +LL | u64::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i64::from_le_bytes` + --> $DIR/endian_bytes.rs:57:9 + | +LL | i64::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u128::from_le_bytes` + --> $DIR/endian_bytes.rs:58:9 + | +LL | u128::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `i128::from_le_bytes` + --> $DIR/endian_bytes.rs:59:9 + | +LL | i128::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `usize::from_le_bytes` + --> $DIR/endian_bytes.rs:60:9 + | +LL | usize::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `isize::from_le_bytes` + --> $DIR/endian_bytes.rs:61:9 + | +LL | isize::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `f32::from_le_bytes` + --> $DIR/endian_bytes.rs:62:9 + | +LL | f32::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `f64::from_le_bytes` + --> $DIR/endian_bytes.rs:63:9 + | +LL | f64::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little() { fn_body!(); } + | ---------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:70:9 + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:71:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_be_bytes` method + --> $DIR/endian_bytes.rs:76:9 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_le_bytes` instead + = note: `-D clippy::big-endian-bytes` implied by `-D warnings` + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_be_bytes` + --> $DIR/endian_bytes.rs:77:9 + | +LL | u8::from_be_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:70:9 + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:71:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:73:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:74:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn host_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:70:9 + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:71:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:73:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:74:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_be_bytes` method + --> $DIR/endian_bytes.rs:76:9 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_be_bytes` + --> $DIR/endian_bytes.rs:77:9 + | +LL | u8::from_be_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn no_help() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:73:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:74:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_be_bytes` method + --> $DIR/endian_bytes.rs:76:9 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_be_bytes` + --> $DIR/endian_bytes.rs:77:9 + | +LL | u8::from_be_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:70:9 + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:71:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:73:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:74:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn little_encourage_big() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_be_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_le_bytes` method + --> $DIR/endian_bytes.rs:73:9 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_le_bytes` + --> $DIR/endian_bytes.rs:74:9 + | +LL | u8::from_le_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_be_bytes` method + --> $DIR/endian_bytes.rs:76:9 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_be_bytes` + --> $DIR/endian_bytes.rs:77:9 + | +LL | u8::from_be_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_host() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use the native endianness instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_ne_bytes` method + --> $DIR/endian_bytes.rs:70:9 + | +LL | 2u8.to_ne_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_ne_bytes` + --> $DIR/endian_bytes.rs:71:9 + | +LL | u8::from_ne_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the `u8::to_be_bytes` method + --> $DIR/endian_bytes.rs:76:9 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::to_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: usage of the function `u8::from_be_bytes` + --> $DIR/endian_bytes.rs:77:9 + | +LL | u8::from_be_bytes(todo!()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | fn big_encourage_little() { fn_body_smol!(); } + | --------------- in this macro invocation + | + = help: use `u8::from_le_bytes` instead + = note: this error originates in the macro `fn_body_smol` (in Nightly builds, run with -Z macro-backtrace for more info) + +<<<<<<< HEAD +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:73:5 + | +LL | 2u32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:74:5 + | +LL | 2i32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:75:5 + | +LL | 2u64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:76:5 + | +LL | 2i64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:77:5 + | +LL | 2u128.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:78:5 + | +LL | 2i128.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:79:5 + | +LL | 2.0f32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:80:5 + | +LL | 2.0f64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:81:5 + | +LL | 2usize.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:82:5 + | +LL | 2isize.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + | + = help: use `to_le_bytes` instead + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:102:5 + | +LL | 2u8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:103:5 + | +LL | 2i8.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:104:5 + | +LL | 2u16.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:105:5 + | +LL | 2i16.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:106:5 + | +LL | 2u32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:107:5 + | +LL | 2i32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:108:5 + | +LL | 2u64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:109:5 + | +LL | 2i64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:110:5 + | +LL | 2u128.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:111:5 + | +LL | 2i128.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:112:5 + | +LL | 2usize.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:113:5 + | +LL | 2isize.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:114:5 + | +LL | 2.0f32.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_le_bytes` + --> $DIR/endian_bytes.rs:115:5 + | +LL | 2.0f64.to_le_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:135:5 + | +LL | 2u8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:136:5 + | +LL | 2i8.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:137:5 + | +LL | 2u16.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:138:5 + | +LL | 2i16.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:139:5 + | +LL | 2u32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:140:5 + | +LL | 2i32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:141:5 + | +LL | 2u64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:142:5 + | +LL | 2i64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:143:5 + | +LL | 2u128.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:144:5 + | +LL | 2i128.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:145:5 + | +LL | 2usize.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:146:5 + | +LL | 2isize.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:147:5 + | +LL | 2.0f32.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: use of the method `to_be_bytes` + --> $DIR/endian_bytes.rs:148:5 + | +LL | 2.0f64.to_be_bytes(); + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 145 previous errors +>>>>>>> 3ab6aeefb (`to_xx_bytes` implemented, `from_xx_bytes` todo) +======= +error: aborting due to 86 previous errors +>>>>>>> 97a0ccc1d (implement `host_endian_bytes` and the other two) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/eta.fixed b/tests/ui/eta.fixed index bf44bcb564ec..7f2c4852ace7 100644 --- a/tests/ui/eta.fixed +++ b/tests/ui/eta.fixed @@ -52,7 +52,23 @@ fn main() { fn test(x: impl Fn(usize, usize) -> T) -> T { x(1, 2) } +<<<<<<< HEAD +<<<<<<< HEAD test(|start, end| start..=end); +======= +<<<<<<< HEAD +<<<<<<< HEAD + test(|start, end| start..=end); +======= + test(core::ops::RangeInclusive::new); +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + test(|start, end| start..=end); +>>>>>>> 9ff34acf2 (actually don't lint for inclusive range) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + test(|start, end| start..=end); +>>>>>>> 615b25c20 (Rebase attempt number 2) } trait TestTrait { diff --git a/tests/ui/eta.stderr b/tests/ui/eta.stderr index 0ac0b901df44..28190e1e04e3 100644 --- a/tests/ui/eta.stderr +++ b/tests/ui/eta.stderr @@ -31,7 +31,32 @@ LL | let e = Some(1u8).map(|a| generic(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `generic` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:94:51 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:94:51 +======= + --> $DIR/eta.rs:54:10 + | +LL | test(|start, end| start..=end); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `core::ops::RangeInclusive::new` + +error: redundant closure +======= +>>>>>>> 9ff34acf2 (actually don't lint for inclusive range) + --> $DIR/eta.rs:93:51 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:94:51 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:94:51 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `TestStruct::foo` @@ -39,121 +64,441 @@ LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.foo()); = note: `-D clippy::redundant-closure-for-method-calls` implied by `-D warnings` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:95:51 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:95:51 +======= + --> $DIR/eta.rs:94:51 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:95:51 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:95:51 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e = Some(TestStruct { some_ref: &i }).map(|a| a.trait_foo()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `TestTrait::trait_foo` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:97:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:97:42 +======= + --> $DIR/eta.rs:96:42 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:97:42 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:97:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e = Some(&mut vec![1, 2, 3]).map(|v| v.clear()); | ^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::vec::Vec::clear` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:101:29 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:101:29 +======= + --> $DIR/eta.rs:100:29 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:101:29 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:101:29 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e = Some("str").map(|s| s.to_string()); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `std::string::ToString::to_string` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:102:27 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:102:27 +======= + --> $DIR/eta.rs:101:27 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:102:27 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:102:27 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e = Some('a').map(|s| s.to_uppercase()); | ^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_uppercase` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:104:65 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:104:65 +======= + --> $DIR/eta.rs:103:65 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:104:65 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:104:65 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let e: std::vec::Vec = vec!['a', 'b', 'c'].iter().map(|c| c.to_ascii_uppercase()).collect(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `char::to_ascii_uppercase` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:167:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:167:22 +======= + --> $DIR/eta.rs:166:22 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:167:22 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:167:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | requires_fn_once(|| x()); | ^^^^^^ help: replace the closure with the function itself: `x` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:174:27 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:174:27 +======= + --> $DIR/eta.rs:173:27 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:174:27 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:174:27 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let a = Some(1u8).map(|a| foo_ptr(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `foo_ptr` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:179:27 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:179:27 +======= + --> $DIR/eta.rs:178:27 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:179:27 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/eta.rs:179:27 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let a = Some(1u8).map(|a| closure(a)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `closure` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:211:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:211:28 +======= + --> $DIR/eta.rs:210:28 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:211:28 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:211:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | x.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:212:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:212:28 +======= + --> $DIR/eta.rs:211:28 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:212:28 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:212:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | y.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut add_to_res` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:213:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:213:28 +======= + --> $DIR/eta.rs:212:28 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:213:28 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:213:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | z.into_iter().for_each(|x| add_to_res(x)); | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `add_to_res` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:220:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:220:21 +======= + --> $DIR/eta.rs:219:21 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:220:21 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:220:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | Some(1).map(|n| closure(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut closure` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:224:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:224:21 +======= + --> $DIR/eta.rs:223:21 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:224:21 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/eta.rs:224:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | Some(1).map(|n| in_loop(n)); | ^^^^^^^^^^^^^^ help: replace the closure with the function itself: `in_loop` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:317:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:317:18 +======= + --> $DIR/eta.rs:316:18 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:317:18 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:317:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | takes_fn_mut(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:320:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:320:19 +======= + --> $DIR/eta.rs:319:19 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:320:19 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:320:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | takes_fn_once(|| f()); | ^^^^^^ help: replace the closure with the function itself: `&mut f` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:324:26 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:324:26 +======= + --> $DIR/eta.rs:323:26 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:324:26 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/eta.rs:324:26 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | move || takes_fn_mut(|| f_used_once()) | ^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `&mut f_used_once` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:336:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:336:19 +======= + --> $DIR/eta.rs:335:19 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:336:19 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:336:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | array_opt.map(|a| a.as_slice()); | ^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8; 3]>::as_slice` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:339:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/eta.rs:339:19 +======= + --> $DIR/eta.rs:338:19 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:339:19 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:339:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | slice_opt.map(|s| s.len()); | ^^^^^^^^^^^ help: replace the closure with the method itself: `<[u8]>::len` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:342:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:342:17 +======= + --> $DIR/eta.rs:341:17 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= --> $DIR/eta.rs:342:17 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/eta.rs:342:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | ptr_opt.map(|p| p.is_null()); | ^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `<*const usize>::is_null` error: redundant closure +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:346:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/eta.rs:346:17 +======= + --> $DIR/eta.rs:345:17 +>>>>>>> 2c7cf2cfa (handle RangeInclusive function desugar) +======= + --> $DIR/eta.rs:346:17 +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/eta.rs:346:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | dyn_opt.map(|d| d.method_on_dyn()); | ^^^^^^^^^^^^^^^^^^^^^ help: replace the closure with the method itself: `::method_on_dyn` diff --git a/tests/ui/excessive_precision.fixed b/tests/ui/excessive_precision.fixed index 7bb4da453c1c..5056e3d4b5ad 100644 --- a/tests/ui/excessive_precision.fixed +++ b/tests/ui/excessive_precision.fixed @@ -1,5 +1,15 @@ //@run-rustfix #![warn(clippy::excessive_precision)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a89903492 (Don't lint `excessive_precision` on inf) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( dead_code, overflowing_literals, @@ -7,6 +17,18 @@ clippy::print_literal, clippy::useless_vec )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(dead_code, unused_variables, clippy::print_literal, clippy::useless_vec)] +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +>>>>>>> a89903492 (Don't lint `excessive_precision` on inf) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { // Consts diff --git a/tests/ui/excessive_precision.rs b/tests/ui/excessive_precision.rs index e8d6ab6870a4..5c2c8e1faf79 100644 --- a/tests/ui/excessive_precision.rs +++ b/tests/ui/excessive_precision.rs @@ -1,5 +1,15 @@ //@run-rustfix #![warn(clippy::excessive_precision)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a89903492 (Don't lint `excessive_precision` on inf) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( dead_code, overflowing_literals, @@ -7,6 +17,18 @@ clippy::print_literal, clippy::useless_vec )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(dead_code, unused_variables, clippy::print_literal, clippy::useless_vec)] +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +>>>>>>> a89903492 (Don't lint `excessive_precision` on inf) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { // Consts diff --git a/tests/ui/explicit_deref_methods.fixed b/tests/ui/explicit_deref_methods.fixed index 4d72b58cdf86..14ab5474e4df 100644 --- a/tests/ui/explicit_deref_methods.fixed +++ b/tests/ui/explicit_deref_methods.fixed @@ -7,8 +7,27 @@ clippy::explicit_auto_deref, clippy::needless_borrow, clippy::no_effect, +<<<<<<< HEAD +<<<<<<< HEAD clippy::uninlined_format_args, clippy::unnecessary_literal_unwrap +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +======= + clippy::uninlined_format_args +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +>>>>>>> 615b25c20 (Rebase attempt number 2) )] use std::ops::{Deref, DerefMut}; @@ -76,16 +95,50 @@ fn main() { let opt_a = Some(a.clone()); let b = &*opt_a.unwrap(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified + // syntax + + Aaa::deref(&Aaa); + Aaa::deref_mut(&mut Aaa); + ::deref(&Aaa); + ::deref_mut(&mut Aaa); + let mut aaa = Aaa; + Aaa::deref(&aaa); + Aaa::deref_mut(&mut aaa); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // make sure `Aaa::deref` instead of `aaa.deref()` works as well as fully qualified syntax +======= // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified // syntax +>>>>>>> eed466281 (ignore `Foo::deref` altogether) Aaa::deref(&Aaa); Aaa::deref_mut(&mut Aaa); ::deref(&Aaa); ::deref_mut(&mut Aaa); let mut aaa = Aaa; +<<<<<<< HEAD + &*aaa; + &mut *aaa; +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= Aaa::deref(&aaa); Aaa::deref_mut(&mut aaa); +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // following should not require linting diff --git a/tests/ui/explicit_deref_methods.rs b/tests/ui/explicit_deref_methods.rs index fcd945de3386..b8618deefc4f 100644 --- a/tests/ui/explicit_deref_methods.rs +++ b/tests/ui/explicit_deref_methods.rs @@ -7,8 +7,27 @@ clippy::explicit_auto_deref, clippy::needless_borrow, clippy::no_effect, +<<<<<<< HEAD +<<<<<<< HEAD clippy::uninlined_format_args, clippy::unnecessary_literal_unwrap +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +======= + clippy::uninlined_format_args +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::uninlined_format_args, + clippy::unnecessary_literal_unwrap +>>>>>>> 615b25c20 (Rebase attempt number 2) )] use std::ops::{Deref, DerefMut}; @@ -76,8 +95,27 @@ fn main() { let opt_a = Some(a.clone()); let b = opt_a.unwrap().deref(); +<<<<<<< HEAD +<<<<<<< HEAD + // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified + // syntax +======= +<<<<<<< HEAD +<<<<<<< HEAD + // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified + // syntax +======= + // make sure `Aaa::deref` instead of `aaa.deref()` works as well as fully qualified syntax +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified + // syntax +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // make sure `Aaa::deref` instead of `aaa.deref()` is not linted, as well as fully qualified // syntax +>>>>>>> 615b25c20 (Rebase attempt number 2) Aaa::deref(&Aaa); Aaa::deref_mut(&mut Aaa); diff --git a/tests/ui/explicit_deref_methods.stderr b/tests/ui/explicit_deref_methods.stderr index 362e559b21a5..5764f461c7bd 100644 --- a/tests/ui/explicit_deref_methods.stderr +++ b/tests/ui/explicit_deref_methods.stderr @@ -1,5 +1,21 @@ error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:54:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:54:19 +======= + --> $DIR/explicit_deref_methods.rs:53:19 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:54:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:54:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: &str = a.deref(); | ^^^^^^^^^ help: try: `&*a` @@ -7,67 +23,283 @@ LL | let b: &str = a.deref(); = note: `-D clippy::explicit-deref-methods` implied by `-D warnings` error: explicit `deref_mut` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:56:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:56:23 +======= + --> $DIR/explicit_deref_methods.rs:55:23 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:56:23 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:56:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: &mut str = a.deref_mut(); | ^^^^^^^^^^^^^ help: try: `&mut **a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:59:39 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:59:39 +======= + --> $DIR/explicit_deref_methods.rs:58:39 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:59:39 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:59:39 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:59:50 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:59:50 +======= + --> $DIR/explicit_deref_methods.rs:58:50 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= --> $DIR/explicit_deref_methods.rs:59:50 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:59:50 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: String = format!("{}, {}", a.deref(), a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:61:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:61:20 +======= + --> $DIR/explicit_deref_methods.rs:60:20 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= --> $DIR/explicit_deref_methods.rs:61:20 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:61:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | println!("{}", a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:64:11 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:64:11 +======= + --> $DIR/explicit_deref_methods.rs:63:11 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:64:11 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_deref_methods.rs:64:11 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | match a.deref() { | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:68:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:68:28 +======= + --> $DIR/explicit_deref_methods.rs:67:28 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:68:28 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_deref_methods.rs:68:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: String = concat(a.deref()); | ^^^^^^^^^ help: try: `&*a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:70:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:70:13 +======= + --> $DIR/explicit_deref_methods.rs:69:13 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:70:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:70:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b = just_return(a).deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:72:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:72:28 +======= + --> $DIR/explicit_deref_methods.rs:71:28 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:72:28 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_deref_methods.rs:72:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: String = concat(just_return(a).deref()); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `just_return(a)` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:74:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:74:19 +======= + --> $DIR/explicit_deref_methods.rs:73:19 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:74:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:74:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: &str = a.deref().deref(); | ^^^^^^^^^^^^^^^^^ help: try: `&**a` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:77:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_deref_methods.rs:77:13 +======= + --> $DIR/explicit_deref_methods.rs:76:13 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:77:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_deref_methods.rs:77:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b = opt_a.unwrap().deref(); | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `&*opt_a.unwrap()` error: explicit `deref` method call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:114:31 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_deref_methods.rs:114:31 +======= + --> $DIR/explicit_deref_methods.rs:80:5 + | +LL | Aaa::deref(&Aaa); + | ^^^^^^^^^^^^^^^^ help: try this: `&*Aaa` + +error: explicit `deref_mut` method call + --> $DIR/explicit_deref_methods.rs:81:5 + | +LL | Aaa::deref_mut(&mut Aaa); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut *Aaa` + +error: explicit `deref` method call + --> $DIR/explicit_deref_methods.rs:82:5 + | +LL | ::deref(&Aaa); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&*Aaa` + +error: explicit `deref_mut` method call + --> $DIR/explicit_deref_methods.rs:83:5 + | +LL | ::deref_mut(&mut Aaa); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut *Aaa` + +error: explicit `deref` method call + --> $DIR/explicit_deref_methods.rs:85:5 + | +LL | Aaa::deref(&aaa); + | ^^^^^^^^^^^^^^^^ help: try this: `&*aaa` + +error: explicit `deref_mut` method call + --> $DIR/explicit_deref_methods.rs:86:5 + | +LL | Aaa::deref_mut(&mut aaa); + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut *aaa` + +error: explicit `deref` method call + --> $DIR/explicit_deref_methods.rs:112:31 +>>>>>>> 8188da361 (Fix suggestion on fully qualified syntax) +======= + --> $DIR/explicit_deref_methods.rs:113:31 +>>>>>>> eed466281 (ignore `Foo::deref` altogether) +======= + --> $DIR/explicit_deref_methods.rs:114:31 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_deref_methods.rs:114:31 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let b: &str = expr_deref!(a.deref()); | ^^^^^^^^^ help: try: `&*a` diff --git a/tests/ui/explicit_into_iter_loop.fixed b/tests/ui/explicit_into_iter_loop.fixed index dcef63403114..2d98856f2b43 100644 --- a/tests/ui/explicit_into_iter_loop.fixed +++ b/tests/ui/explicit_into_iter_loop.fixed @@ -7,7 +7,25 @@ fn main() { where for<'a> &'a T: IntoIterator, { +<<<<<<< HEAD +<<<<<<< HEAD for _ in iterator {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + for _ in iterator {} +======= + for i in iterator { + println!("{}", i); + } +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + for _ in iterator {} +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for _ in iterator {} +>>>>>>> 615b25c20 (Rebase attempt number 2) } struct T; @@ -15,6 +33,14 @@ fn main() { type Item = (); type IntoIter = std::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) unimplemented!() } } @@ -23,10 +49,47 @@ fn main() { for _ in &t {} let r = &t; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + vec![].into_iter() +======= + unimplemented!() +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) + } + } + + let mut t = T; + for _ in &t {} + + let r = &t; +<<<<<<< HEAD + let rr = &&t; + + // This case is handled by `explicit_iter_loop`. No idea why. + for _ in t.into_iter() {} + +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) for _ in r {} // No suggestion for this. // We'd have to suggest `for _ in *rr {}` which is less clear. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rr = &&t; for _ in rr.into_iter() {} @@ -48,6 +111,19 @@ fn main() { let mr = &mut u; for _ in &mut *mr {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + for _ in rr.into_iter() {} + +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Issue #6900 struct S; impl S { diff --git a/tests/ui/explicit_into_iter_loop.rs b/tests/ui/explicit_into_iter_loop.rs index bc048ed302bf..ab0111ab2b9c 100644 --- a/tests/ui/explicit_into_iter_loop.rs +++ b/tests/ui/explicit_into_iter_loop.rs @@ -7,7 +7,25 @@ fn main() { where for<'a> &'a T: IntoIterator, { +<<<<<<< HEAD +<<<<<<< HEAD for _ in iterator.into_iter() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + for _ in iterator.into_iter() {} +======= + for i in iterator.into_iter() { + println!("{}", i); + } +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + for _ in iterator.into_iter() {} +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for _ in iterator.into_iter() {} +>>>>>>> 615b25c20 (Rebase attempt number 2) } struct T; @@ -15,18 +33,58 @@ fn main() { type Item = (); type IntoIter = std::vec::IntoIter; fn into_iter(self) -> Self::IntoIter { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + unimplemented!() + } + } + + let mut t = T; + for _ in t.into_iter() {} + + let r = &t; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + vec![].into_iter() +======= unimplemented!() +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) } } let mut t = T; for _ in t.into_iter() {} +<<<<<<< HEAD +>>>>>>> 974900b50 (Split `for_loops` tests) +======= let r = &t; +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) for _ in r.into_iter() {} // No suggestion for this. // We'd have to suggest `for _ in *rr {}` which is less clear. +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rr = &&t; for _ in rr.into_iter() {} @@ -48,6 +106,19 @@ fn main() { let mr = &mut u; for _ in mr.into_iter() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + for _ in rr.into_iter() {} + +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Issue #6900 struct S; impl S { diff --git a/tests/ui/explicit_into_iter_loop.stderr b/tests/ui/explicit_into_iter_loop.stderr index fa89b884fa0f..c1df0b3f6856 100644 --- a/tests/ui/explicit_into_iter_loop.stderr +++ b/tests/ui/explicit_into_iter_loop.stderr @@ -1,12 +1,38 @@ error: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/explicit_into_iter_loop.rs:10:18 | +<<<<<<< HEAD +<<<<<<< HEAD LL | for _ in iterator.into_iter() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD +LL | for _ in iterator.into_iter() {} +======= +LL | for i in iterator.into_iter() { +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +LL | for _ in iterator.into_iter() {} +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +LL | for _ in iterator.into_iter() {} +>>>>>>> 615b25c20 (Rebase attempt number 2) | ^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `iterator` | = note: `-D clippy::explicit-into-iter-loop` implied by `-D warnings` error: it is more concise to loop over containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/explicit_into_iter_loop.rs:23:14 | LL | for _ in t.into_iter() {} @@ -14,10 +40,32 @@ LL | for _ in t.into_iter() {} error: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/explicit_into_iter_loop.rs:26:14 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/explicit_into_iter_loop.rs:31:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in r.into_iter() {} | ^^^^^^^^^^^^^ help: to write this more concisely, try: `r` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it is more concise to loop over containers instead of using explicit iteration methods --> $DIR/explicit_into_iter_loop.rs:34:14 | @@ -37,4 +85,16 @@ LL | for _ in mr.into_iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut *mr` error: aborting due to 6 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 2 previous errors +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 482baf2bc (Fix `explicit_into_iter_loop` with mutable references) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/explicit_iter_loop.fixed b/tests/ui/explicit_iter_loop.fixed index 746ef813c048..702150feb342 100644 --- a/tests/ui/explicit_iter_loop.fixed +++ b/tests/ui/explicit_iter_loop.fixed @@ -17,6 +17,16 @@ fn main() { for _ in &vec {} for _ in &mut vec {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rvec = &vec; for _ in rvec {} @@ -24,6 +34,17 @@ fn main() { for _ in &*rmvec {} for _ in &mut *rmvec {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) for _ in &vec {} // these are fine for _ in &mut vec {} // these are fine @@ -36,6 +57,16 @@ fn main() { let ll: LinkedList<()> = LinkedList::new(); for _ in &ll {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rll = ≪ for _ in rll {} @@ -43,6 +74,20 @@ fn main() { for _ in &vd {} let rvd = &vd; for _ in rvd {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + + let vd: VecDeque<()> = VecDeque::new(); + for _ in &vd {} +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let bh: BinaryHeap<()> = BinaryHeap::new(); for _ in &bh {} @@ -148,7 +193,28 @@ fn main() { let mut x = CustomType; for _ in &x {} for _ in &mut x {} +<<<<<<< HEAD +<<<<<<< HEAD + + let r = &x; + for _ in r {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + + let r = &x; + for _ in r {} +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + + let r = &x; + for _ in r {} +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let r = &x; for _ in r {} +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/explicit_iter_loop.rs b/tests/ui/explicit_iter_loop.rs index fba230ee0eea..a1b2bd901edd 100644 --- a/tests/ui/explicit_iter_loop.rs +++ b/tests/ui/explicit_iter_loop.rs @@ -17,6 +17,16 @@ fn main() { for _ in vec.iter() {} for _ in vec.iter_mut() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rvec = &vec; for _ in rvec.iter() {} @@ -24,6 +34,17 @@ fn main() { for _ in rmvec.iter() {} for _ in rmvec.iter_mut() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) for _ in &vec {} // these are fine for _ in &mut vec {} // these are fine @@ -36,6 +57,16 @@ fn main() { let ll: LinkedList<()> = LinkedList::new(); for _ in ll.iter() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let rll = ≪ for _ in rll.iter() {} @@ -43,6 +74,20 @@ fn main() { for _ in vd.iter() {} let rvd = &vd; for _ in rvd.iter() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + + let vd: VecDeque<()> = VecDeque::new(); + for _ in vd.iter() {} +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let bh: BinaryHeap<()> = BinaryHeap::new(); for _ in bh.iter() {} @@ -148,7 +193,28 @@ fn main() { let mut x = CustomType; for _ in x.iter() {} for _ in x.iter_mut() {} +<<<<<<< HEAD +<<<<<<< HEAD + + let r = &x; + for _ in r.iter() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + + let r = &x; + for _ in r.iter() {} +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + + let r = &x; + for _ in r.iter() {} +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let r = &x; for _ in r.iter() {} +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/explicit_iter_loop.stderr b/tests/ui/explicit_iter_loop.stderr index 94a264dcea8d..a07811c5d1cf 100644 --- a/tests/ui/explicit_iter_loop.stderr +++ b/tests/ui/explicit_iter_loop.stderr @@ -17,6 +17,16 @@ LL | for _ in vec.iter_mut() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/explicit_iter_loop.rs:21:14 | LL | for _ in rvec.iter() {} @@ -36,18 +46,62 @@ LL | for _ in rmvec.iter_mut() {} error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/explicit_iter_loop.rs:30:14 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/explicit_iter_loop.rs:23:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in [1, 2, 3].iter() {} | ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_iter_loop.rs:32:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:32:14 +======= + --> $DIR/explicit_iter_loop.rs:25:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:32:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:32:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in (&mut [1, 2, 3]).iter() {} | ^^^^^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&*(&mut [1, 2, 3])` error: the method `iter` doesn't need a mutable reference +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:32:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_iter_loop.rs:32:14 +======= + --> $DIR/explicit_iter_loop.rs:25:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:32:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:32:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in (&mut [1, 2, 3]).iter() {} | ^^^^^^^^^^^^^^^^ @@ -55,24 +109,82 @@ LL | for _ in (&mut [1, 2, 3]).iter() {} = note: `-D clippy::unnecessary-mut-passed` implied by `-D warnings` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:34:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:34:14 +======= + --> $DIR/explicit_iter_loop.rs:27:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= --> $DIR/explicit_iter_loop.rs:34:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:34:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in [0; 32].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:35:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:35:14 +======= + --> $DIR/explicit_iter_loop.rs:28:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= --> $DIR/explicit_iter_loop.rs:35:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:35:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in [0; 33].iter() {} | ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 33]` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:38:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_iter_loop.rs:38:14 +======= + --> $DIR/explicit_iter_loop.rs:31:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:38:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:38:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in ll.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&ll` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/explicit_iter_loop.rs:40:14 | LL | for _ in rll.iter() {} @@ -80,11 +192,33 @@ LL | for _ in rll.iter() {} error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/explicit_iter_loop.rs:43:14 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/explicit_iter_loop.rs:34:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in vd.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&vd` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/explicit_iter_loop.rs:45:14 | LL | for _ in rvd.iter() {} @@ -92,46 +226,164 @@ LL | for _ in rvd.iter() {} error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/explicit_iter_loop.rs:48:14 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/explicit_iter_loop.rs:37:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in bh.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bh` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:51:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_iter_loop.rs:51:14 +======= + --> $DIR/explicit_iter_loop.rs:40:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:51:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:51:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in hm.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hm` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:54:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:54:14 +======= + --> $DIR/explicit_iter_loop.rs:43:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:54:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_iter_loop.rs:54:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in bt.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bt` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:57:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:57:14 +======= + --> $DIR/explicit_iter_loop.rs:46:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:57:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_iter_loop.rs:57:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in hs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&hs` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/explicit_iter_loop.rs:60:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:60:14 +======= + --> $DIR/explicit_iter_loop.rs:49:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:60:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:60:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in bs.iter() {} | ^^^^^^^^^ help: to write this more concisely, try: `&bs` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:149:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:149:14 +======= + --> $DIR/explicit_iter_loop.rs:138:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= --> $DIR/explicit_iter_loop.rs:149:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/explicit_iter_loop.rs:149:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in x.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `&x` error: it is more concise to loop over references to containers instead of using explicit iteration methods +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:150:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/explicit_iter_loop.rs:150:14 +======= + --> $DIR/explicit_iter_loop.rs:139:14 +>>>>>>> 974900b50 (Split `for_loops` tests) +======= + --> $DIR/explicit_iter_loop.rs:150:14 +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/explicit_iter_loop.rs:150:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | for _ in x.iter_mut() {} | ^^^^^^^^^^^^ help: to write this more concisely, try: `&mut x` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it is more concise to loop over references to containers instead of using explicit iteration methods --> $DIR/explicit_iter_loop.rs:153:14 | @@ -139,4 +391,16 @@ LL | for _ in r.iter() {} | ^^^^^^^^ help: to write this more concisely, try: `r` error: aborting due to 22 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 16 previous errors +>>>>>>> 974900b50 (Split `for_loops` tests) +======= +>>>>>>> 949712c90 (Reborrow mutable references in `explicit_iter_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/extra_unused_type_parameters.fixed b/tests/ui/extra_unused_type_parameters.fixed index 8420df6634d9..a77fda5fda5a 100644 --- a/tests/ui/extra_unused_type_parameters.fixed +++ b/tests/ui/extra_unused_type_parameters.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> f0eb40c98 (Avoid linting on procedural macros) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused, clippy::needless_lifetimes)] #![warn(clippy::extra_unused_type_parameters)] diff --git a/tests/ui/extra_unused_type_parameters.rs b/tests/ui/extra_unused_type_parameters.rs index f63535d7ae6e..ad4524812ba5 100644 --- a/tests/ui/extra_unused_type_parameters.rs +++ b/tests/ui/extra_unused_type_parameters.rs @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> f0eb40c98 (Avoid linting on procedural macros) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused, clippy::needless_lifetimes)] #![warn(clippy::extra_unused_type_parameters)] diff --git a/tests/ui/format.fixed b/tests/ui/format.fixed index 2e24e07ea268..74bc28c68409 100644 --- a/tests/ui/format.fixed +++ b/tests/ui/format.fixed @@ -7,7 +7,22 @@ clippy::to_string_in_format_args, clippy::needless_borrow, clippy::uninlined_format_args, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_raw_string_hashes, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_raw_string_hashes, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::needless_raw_string_hashes, +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_raw_string_hashes, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::useless_vec )] diff --git a/tests/ui/format.rs b/tests/ui/format.rs index 0e64a310b01e..949254b57619 100644 --- a/tests/ui/format.rs +++ b/tests/ui/format.rs @@ -7,7 +7,22 @@ clippy::to_string_in_format_args, clippy::needless_borrow, clippy::uninlined_format_args, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_raw_string_hashes, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_raw_string_hashes, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::needless_raw_string_hashes, +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_raw_string_hashes, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::useless_vec )] diff --git a/tests/ui/format.stderr b/tests/ui/format.stderr index 78a11a3354f6..304cf8f8df69 100644 --- a/tests/ui/format.stderr +++ b/tests/ui/format.stderr @@ -1,5 +1,21 @@ error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:21:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:21:5 +======= + --> $DIR/format.rs:20:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:21:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:21:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` @@ -7,19 +23,67 @@ LL | format!("foo"); = note: `-D clippy::useless-format` implied by `-D warnings` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:22:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:22:5 +======= + --> $DIR/format.rs:21:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/format.rs:22:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:22:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{{}}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:23:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:23:5 +======= + --> $DIR/format.rs:22:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:23:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:23:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{{}} abc {{}}"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:24:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:24:5 +======= + --> $DIR/format.rs:23:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:24:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:24:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / format!( LL | | r##"foo {{}} @@ -34,67 +98,243 @@ LL ~ " bar"##.to_string(); | error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:29:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:29:13 +======= + --> $DIR/format.rs:28:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:29:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:29:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = format!(""); | ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:31:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:31:5 +======= + --> $DIR/format.rs:30:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:31:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:31:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:39:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:39:5 +======= + --> $DIR/format.rs:38:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:39:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:39:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:69:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:69:5 +======= + --> $DIR/format.rs:68:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:69:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:69:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:71:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:71:5 +======= + --> $DIR/format.rs:70:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:71:5 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:71:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:75:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:75:18 +======= + --> $DIR/format.rs:74:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:75:18 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:75:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(format!("{}", a + "bar")); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:79:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:79:22 +======= + --> $DIR/format.rs:78:22 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:79:22 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:79:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s: String = format!("{}", &*v.join("/n")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("/n")).to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:85:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:85:13 +======= + --> $DIR/format.rs:84:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:85:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:85:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = format!("{x}"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:87:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:87:13 +======= + --> $DIR/format.rs:86:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:87:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:87:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = format!("{y}", y = x); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/format.rs:91:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:91:13 +======= + --> $DIR/format.rs:90:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:91:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/format.rs:91:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = format!("{abc}"); | ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()` error: useless use of `format!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:93:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/format.rs:93:13 +======= + --> $DIR/format.rs:92:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/format.rs:93:13 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/format.rs:93:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = format!("{xx}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()` diff --git a/tests/ui/from_over_into.fixed b/tests/ui/from_over_into.fixed index d96b68a9159a..12cbbc6a7571 100644 --- a/tests/ui/from_over_into.fixed +++ b/tests/ui/from_over_into.fixed @@ -91,4 +91,32 @@ fn msrv_1_41() { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +type Opaque = impl Sized; +struct IntoOpaque; +impl Into for IntoOpaque { + fn into(self) -> Opaque {} +} + +<<<<<<< HEAD +pub struct Lval(T); + +pub struct Rval(T); + +impl Into> for Lval { + fn into(self) -> Rval { + Rval(self) + } +} + +>>>>>>> d4b388eb4 (Add from_over_into replace for type in `Self` reference) +======= +>>>>>>> b2c85b31b (Move bail into lint to prevent no-linting, move to unfixable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/from_over_into.rs b/tests/ui/from_over_into.rs index da8fe04f4760..c15a83ab78f4 100644 --- a/tests/ui/from_over_into.rs +++ b/tests/ui/from_over_into.rs @@ -91,4 +91,32 @@ fn msrv_1_41() { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +type Opaque = impl Sized; +struct IntoOpaque; +impl Into for IntoOpaque { + fn into(self) -> Opaque {} +} + +<<<<<<< HEAD +pub struct Lval(T); + +pub struct Rval(T); + +impl Into> for Lval { + fn into(self) -> Rval { + Rval(self) + } +} + +>>>>>>> d4b388eb4 (Add from_over_into replace for type in `Self` reference) +======= +>>>>>>> b2c85b31b (Move bail into lint to prevent no-linting, move to unfixable) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/from_over_into.stderr b/tests/ui/from_over_into.stderr index 498b00de5adb..195ff24b0230 100644 --- a/tests/ui/from_over_into.stderr +++ b/tests/ui/from_over_into.stderr @@ -85,5 +85,37 @@ LL ~ fn from(val: Vec) -> Self { LL ~ FromOverInto(val) | +<<<<<<< HEAD +<<<<<<< HEAD error: aborting due to 6 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +error: an implementation of `From` is preferred since it gives you `Into<_>` for free where the reverse isn't true + --> $DIR/from_over_into.rs:95:1 + | +LL | impl Into> for Lval { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: replace the `Into` implementation with `From>` + | +LL ~ impl From> for Rval> { +LL ~ fn from(val: Lval) -> Self { +LL ~ Rval(val) + | + +>>>>>>> d4b388eb4 (Add from_over_into replace for type in `Self` reference) +error: aborting due to 6 previous errors +======= +error: aborting due to 5 previous errors +>>>>>>> 16f1cf8fd (Ignore from_over_into if it contains Self) +======= +error: aborting due to 6 previous errors +>>>>>>> c10876e6c (from_over_into: Show suggestions for non-Self expanded paths) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: aborting due to 6 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/get_unwrap.fixed b/tests/ui/get_unwrap.fixed index fda334407a9b..1b8a78e551c1 100644 --- a/tests/ui/get_unwrap.fixed +++ b/tests/ui/get_unwrap.fixed @@ -107,3 +107,48 @@ mod issue9909 { assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +mod issue9909 { + #![allow(clippy::identity_op, clippy::unwrap_used, dead_code)] + + fn reduced() { + let f = &[1, 2, 3]; + + // include a borrow in the suggestion, even if the argument is not just a numeric literal + let _x: &i32 = &f[1 + 2]; + + // don't include a borrow here + let _x = f[1 + 2].to_string(); + + // don't include a borrow here + let _x = f[1 + 2].abs(); + } + + // original code: + fn linidx(row: usize, col: usize) -> usize { + row * 1 + col * 3 + } + + fn main_() { + let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; + + for i in 0..2 { + for j in i + 1..3 { + if mat[linidx(j, 3)] > mat[linidx(i, 3)] { + for k in 0..4 { + let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); + let a = x.last_mut().unwrap(); + let b = &mut rest[linidx(j, k) - linidx(i, k) - 1]; + ::std::mem::swap(a, b); + } + } + } + } + assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); + } +} +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/get_unwrap.rs b/tests/ui/get_unwrap.rs index eaf6b005a36b..4b5926c9dede 100644 --- a/tests/ui/get_unwrap.rs +++ b/tests/ui/get_unwrap.rs @@ -107,3 +107,48 @@ mod issue9909 { assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +mod issue9909 { + #![allow(clippy::identity_op, clippy::unwrap_used, dead_code)] + + fn reduced() { + let f = &[1, 2, 3]; + + // include a borrow in the suggestion, even if the argument is not just a numeric literal + let _x: &i32 = f.get(1 + 2).unwrap(); + + // don't include a borrow here + let _x = f.get(1 + 2).unwrap().to_string(); + + // don't include a borrow here + let _x = f.get(1 + 2).unwrap().abs(); + } + + // original code: + fn linidx(row: usize, col: usize) -> usize { + row * 1 + col * 3 + } + + fn main_() { + let mut mat = [1.0f32, 5.0, 9.0, 2.0, 6.0, 10.0, 3.0, 7.0, 11.0, 4.0, 8.0, 12.0]; + + for i in 0..2 { + for j in i + 1..3 { + if mat[linidx(j, 3)] > mat[linidx(i, 3)] { + for k in 0..4 { + let (x, rest) = mat.split_at_mut(linidx(i, k) + 1); + let a = x.last_mut().unwrap(); + let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); + ::std::mem::swap(a, b); + } + } + } + } + assert_eq!([9.0, 5.0, 1.0, 10.0, 6.0, 2.0, 11.0, 7.0, 3.0, 12.0, 8.0, 4.0], mat); + } +} +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/get_unwrap.stderr b/tests/ui/get_unwrap.stderr index c567ed319b5b..a735e5edec6c 100644 --- a/tests/ui/get_unwrap.stderr +++ b/tests/ui/get_unwrap.stderr @@ -188,7 +188,22 @@ LL | let _ = some_vec.get_mut(0..1).unwrap().to_vec(); = help: if you don't want to handle the `None` case gracefully, consider using `expect()` to provide a better panic message error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/get_unwrap.rs:78:24 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/get_unwrap.rs:80:24 +======= + --> $DIR/get_unwrap.rs:78:24 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/get_unwrap.rs:78:24 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _x: &i32 = f.get(1 + 2).unwrap(); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `&f[1 + 2]` @@ -212,4 +227,46 @@ LL | let b = rest.get_mut(linidx(j, k) - linidx(i, k) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `&mut rest[linidx(j, k) - linidx(i, k) - 1]` error: aborting due to 30 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/get_unwrap.rs:77:20 +======= + --> $DIR/get_unwrap.rs:79:24 +>>>>>>> 3122e3d78 (use let chains, move assignments out of block, add tests) +======= + --> $DIR/get_unwrap.rs:80:24 +>>>>>>> 5bd97ac17 (Update tests) + | +LL | let _x: &i32 = f.get(1 + 2).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `&f[1 + 2]` + +error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise + --> $DIR/get_unwrap.rs:83:18 + | +LL | let _x = f.get(1 + 2).unwrap().to_string(); + | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]` + +error: called `.get().unwrap()` on a slice. Using `[]` is more clear and more concise + --> $DIR/get_unwrap.rs:86:18 + | +LL | let _x = f.get(1 + 2).unwrap().abs(); + | ^^^^^^^^^^^^^^^^^^^^^ help: try this: `f[1 + 2]` + +error: called `.get_mut().unwrap()` on a slice. Using `[]` is more clear and more concise + --> $DIR/get_unwrap.rs:103:33 + | +LL | let b = rest.get_mut(linidx(j, k) - linidx(i, k) - 1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this: `&mut rest[linidx(j, k) - linidx(i, k) - 1]` + +<<<<<<< HEAD +error: aborting due to 32 previous errors +>>>>>>> 6331c943f (include a ref if argument is not just a numeric literal) +======= +error: aborting due to 30 previous errors +>>>>>>> 3122e3d78 (use let chains, move assignments out of block, add tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/if_same_then_else2.stderr b/tests/ui/if_same_then_else2.stderr index 56e5f3e45b22..58d1138c2e15 100644 --- a/tests/ui/if_same_then_else2.stderr +++ b/tests/ui/if_same_then_else2.stderr @@ -12,7 +12,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/if_same_then_else2.rs:25:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:25:12 +======= + --> $DIR/if_same_then_else2.rs:24:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/if_same_then_else2.rs:25:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/if_same_then_else2.rs:25:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ @@ -36,7 +52,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:39:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:39:12 +======= + --> $DIR/if_same_then_else2.rs:38:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/if_same_then_else2.rs:39:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/if_same_then_else2.rs:39:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ @@ -55,7 +87,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:46:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:46:12 +======= + --> $DIR/if_same_then_else2.rs:45:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/if_same_then_else2.rs:46:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/if_same_then_else2.rs:46:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ @@ -74,7 +122,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/if_same_then_else2.rs:96:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:96:12 +======= + --> $DIR/if_same_then_else2.rs:95:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/if_same_then_else2.rs:96:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/if_same_then_else2.rs:96:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ @@ -93,7 +157,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:103:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:103:12 +======= + --> $DIR/if_same_then_else2.rs:102:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/if_same_then_else2.rs:103:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/if_same_then_else2.rs:103:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ @@ -113,7 +193,23 @@ LL | | } else { | |_____^ | note: same as this +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:128:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/if_same_then_else2.rs:128:12 +======= + --> $DIR/if_same_then_else2.rs:127:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/if_same_then_else2.rs:128:12 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/if_same_then_else2.rs:128:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | ____________^ diff --git a/tests/ui/ifs_same_cond.rs b/tests/ui/ifs_same_cond.rs index 5c338e3c5c8f..7df1d0287f68 100644 --- a/tests/ui/ifs_same_cond.rs +++ b/tests/ui/ifs_same_cond.rs @@ -1,10 +1,32 @@ #![warn(clippy::ifs_same_cond)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::if_same_then_else, clippy::comparison_chain, clippy::needless_if, clippy::needless_else )] // all empty blocks +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::if_same_then_else, clippy::comparison_chain, clippy::needless_else)] // all empty blocks +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn ifs_same_cond() { let a = 0; diff --git a/tests/ui/items_after_test_module/block_module.rs b/tests/ui/items_after_test_module/block_module.rs index 5136b2557ec1..1482d1e7cc3d 100644 --- a/tests/ui/items_after_test_module/block_module.rs +++ b/tests/ui/items_after_test_module/block_module.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@compile-flags: --test +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@compile-flags: --test +======= +// compile-flags: --test +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= +//@compile-flags: --test +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@compile-flags: --test +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused)] #![warn(clippy::items_after_test_module)] @@ -18,6 +34,19 @@ mod tests { fn should_lint() {} const SHOULD_ALSO_LINT: usize = 1; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= +>>>>>>> 1ac8dc51b (Compact emmited lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! should_not_lint { () => {}; } diff --git a/tests/ui/items_after_test_module/block_module.stderr b/tests/ui/items_after_test_module/block_module.stderr index 1b6257471618..f5f92880b2f5 100644 --- a/tests/ui/items_after_test_module/block_module.stderr +++ b/tests/ui/items_after_test_module/block_module.stderr @@ -1,2 +1,75 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: Option 'test' given more than once +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +error: items were found after the testing module + --> $DIR/block_module.rs:13:1 + | +LL | / mod tests { +LL | | #[test] +LL | | fn hi() {} +LL | | } +... | +LL | | () => {}; +LL | | } + | |_^ + | + = help: move the items to before the testing module was defined + = note: `-D clippy::items-after-test-module` implied by `-D warnings` + +error: aborting due to previous error +<<<<<<< HEAD +======= +error: an item was found after the testing module + --> $DIR/items_after_test_module.rs:18:1 +======= +error: items were found after the testing module + --> $DIR/items_after_test_module.rs:13:1 +>>>>>>> 1ac8dc51b (Compact emmited lint) + | +LL | / mod tests { +LL | | #[test] +LL | | fn hi() {} +LL | | } +... | +LL | | () => {}; +LL | | } + | |_^ + | + = help: move the items to before the testing module was defined + = note: `-D clippy::items-after-test-module` implied by `-D warnings` + +<<<<<<< HEAD +error: an item was found after the testing module + --> $DIR/items_after_test_module.rs:20:1 + | +LL | const SHOULD_ALSO_LINT: usize = 1; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: move the item to before the testing module was defined + +error: aborting due to 2 previous errors +>>>>>>> 0354cee13 (Add lint `items_after_test_module`) +======= +error: aborting due to previous error +>>>>>>> 1ac8dc51b (Compact emmited lint) +======= +>>>>>>> 7e9abb311 (Merge commit '371120bdbf58a331db5dcfb2d9cddc040f486de8' into clippyup) +======= +error: Option 'test' given more than once +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +error: Option 'test' given more than once +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: Option 'test' given more than once +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/iter_nth.stderr b/tests/ui/iter_nth.stderr index 24be814548a2..7900e6cf2526 100644 --- a/tests/ui/iter_nth.stderr +++ b/tests/ui/iter_nth.stderr @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: called `.iter().nth()` on a `Vec` +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter().nth()` on a `Vec` +======= +error: called `.iter().nth()` on a Vec +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +error: called `.iter().nth()` on a `Vec` +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: called `.iter().nth()` on a `Vec` +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/iter_nth.rs:34:23 | LL | let bad_vec = some_vec.iter().nth(3); @@ -23,7 +39,23 @@ LL | let bad_boxed_slice = boxed_slice.iter().nth(3); | = help: calling `.get()` is both faster and more readable +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter().nth()` on a `VecDeque` +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter().nth()` on a `VecDeque` +======= +error: called `.iter().nth()` on a VecDeque +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +error: called `.iter().nth()` on a `VecDeque` +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: called `.iter().nth()` on a `VecDeque` +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/iter_nth.rs:37:29 | LL | let bad_vec_deque = some_vec_deque.iter().nth(3); @@ -31,7 +63,23 @@ LL | let bad_vec_deque = some_vec_deque.iter().nth(3); | = help: calling `.get()` is both faster and more readable +<<<<<<< HEAD +<<<<<<< HEAD error: called `.iter_mut().nth()` on a `Vec` +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter_mut().nth()` on a `Vec` +======= +error: called `.iter_mut().nth()` on a Vec +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +error: called `.iter_mut().nth()` on a `Vec` +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: called `.iter_mut().nth()` on a `Vec` +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/iter_nth.rs:42:23 | LL | let bad_vec = some_vec.iter_mut().nth(3); @@ -47,7 +95,23 @@ LL | let bad_slice = &some_vec[..].iter_mut().nth(3); | = help: calling `.get_mut()` is both faster and more readable +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter_mut().nth()` on a `VecDeque` +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: called `.iter_mut().nth()` on a `VecDeque` +======= +error: called `.iter_mut().nth()` on a VecDeque +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +error: called `.iter_mut().nth()` on a `VecDeque` +>>>>>>> 242807a9c (Don't lint `iter_nth_zero` in `next`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: called `.iter_mut().nth()` on a `VecDeque` +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/iter_nth.rs:48:29 | LL | let bad_vec_deque = some_vec_deque.iter_mut().nth(3); diff --git a/tests/ui/let_underscore_untyped.rs b/tests/ui/let_underscore_untyped.rs index 18630c27f417..5c91c16a1843 100644 --- a/tests/ui/let_underscore_untyped.rs +++ b/tests/ui/let_underscore_untyped.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build: proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build: proc_macros.rs:proc-macro +======= +//@aux-build: proc_macros.rs +>>>>>>> e234dfa63 (Ignoring `let_underscore_untyped` warnings in code from proc macros) +======= +//@aux-build: proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build: proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused)] #![warn(clippy::let_underscore_untyped)] diff --git a/tests/ui/let_with_type_underscore.rs b/tests/ui/let_with_type_underscore.rs index 8214176cfd57..414c4270ee75 100644 --- a/tests/ui/let_with_type_underscore.rs +++ b/tests/ui/let_with_type_underscore.rs @@ -1,7 +1,27 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build: proc_macros.rs:proc-macro #![allow(unused)] #![warn(clippy::let_with_type_underscore)] #![allow(clippy::let_unit_value, clippy::needless_late_init)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +//@aux-build: proc_macros.rs:proc-macro +#![allow(unused)] +#![warn(clippy::let_with_type_underscore)] +#![allow(clippy::let_unit_value, clippy::needless_late_init)] +<<<<<<< HEAD +<<<<<<< HEAD + +extern crate proc_macros; +======= +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; @@ -22,12 +42,45 @@ fn main() { let x = func(); let x: Vec<_> = Vec::::new(); let x: [_; 1] = [1]; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let x : _ = 1; + + // Do not lint from procedural macros + proc_macros::with_span! { + span + let x: _ = (); + // Late initialization + let x: _; + x = (); + // Ensure weird formatting will not break it (hopefully) + let x : _ = 1; + let x +: _ = 1; + let x : + _; + x = (); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= let x : _ = 1; +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) // Do not lint from procedural macros proc_macros::with_span! { span let x: _ = (); +<<<<<<< HEAD +>>>>>>> 0cc1454db (Fix #10498) +======= // Late initialization let x: _; x = (); @@ -38,5 +91,9 @@ fn main() { let x : _; x = (); +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }; } diff --git a/tests/ui/let_with_type_underscore.stderr b/tests/ui/let_with_type_underscore.stderr index a749552c7fac..aba3b2d10ebe 100644 --- a/tests/ui/let_with_type_underscore.stderr +++ b/tests/ui/let_with_type_underscore.stderr @@ -1,36 +1,132 @@ error: variable declared with type underscore +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/let_with_type_underscore.rs:15:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:15:5 +======= + --> $DIR/let_with_type_underscore.rs:14:5 +>>>>>>> 0cc1454db (Fix #10498) +======= + --> $DIR/let_with_type_underscore.rs:15:5 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/let_with_type_underscore.rs:15:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let x: _ = 1; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:15:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:15:10 +======= + --> $DIR/let_with_type_underscore.rs:14:10 +>>>>>>> 0cc1454db (Fix #10498) +======= + --> $DIR/let_with_type_underscore.rs:15:10 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/let_with_type_underscore.rs:15:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let x: _ = 1; | ^^^ = note: `-D clippy::let-with-type-underscore` implied by `-D warnings` error: variable declared with type underscore +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/let_with_type_underscore.rs:16:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:16:5 +======= + --> $DIR/let_with_type_underscore.rs:15:5 +>>>>>>> 0cc1454db (Fix #10498) +======= + --> $DIR/let_with_type_underscore.rs:16:5 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/let_with_type_underscore.rs:16:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: _ = 2; | ^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:16:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/let_with_type_underscore.rs:16:10 +======= + --> $DIR/let_with_type_underscore.rs:15:10 +>>>>>>> 0cc1454db (Fix #10498) +======= + --> $DIR/let_with_type_underscore.rs:16:10 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/let_with_type_underscore.rs:16:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: _ = 2; | ^^^ error: variable declared with type underscore +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:17:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:17:5 +======= + --> $DIR/let_with_type_underscore.rs:16:5 +>>>>>>> 0cc1454db (Fix #10498) +======= --> $DIR/let_with_type_underscore.rs:17:5 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/let_with_type_underscore.rs:17:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let x: _ = func(); | ^^^^^^^^^^^^^^^^^^ | help: remove the explicit type `_` declaration +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:17:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/let_with_type_underscore.rs:17:10 +======= + --> $DIR/let_with_type_underscore.rs:16:10 +>>>>>>> 0cc1454db (Fix #10498) +======= + --> $DIR/let_with_type_underscore.rs:17:10 +>>>>>>> 143ff2dfc (Use type snippet instead of init expr for proc macro check) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/let_with_type_underscore.rs:17:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let x: _ = func(); | ^^^ diff --git a/tests/ui/manual_let_else.rs b/tests/ui/manual_let_else.rs index 381b83409e9d..643fc7d726b1 100644 --- a/tests/ui/manual_let_else.rs +++ b/tests/ui/manual_let_else.rs @@ -147,6 +147,14 @@ fn fire() { Variant::A(0, 0) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let v = if let Variant::A(a, 0) = e() { a } else { return }; // `mut v` is inserted into the pattern @@ -164,6 +172,16 @@ fn fire() { // () is preserved: a bit of an edge case but make sure it stays around let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Tuple structs work let w = if let Some(S { v: x }) = Some(S { v: 0 }) { @@ -185,6 +203,39 @@ fn fire() { } else { return; }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + // Should not be renamed + let v = if let Variant::A(a, 0) = e() { a } else { return }; + // Should be renamed + let v = if let Variant::B(b) = e() { b } else { return }; +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + let v = if let Variant::A(a, 0) = e() { a } else { return }; + + // `mut v` is inserted into the pattern + let mut v = if let Variant::B(b) = e() { b } else { return }; + + // Nesting works + let nested = Ok(Some(e())); + let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { + b + } else { + return; + }; + // dot dot works + let v = if let Variant::A(.., a) = e() { a } else { return }; +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +======= +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn not_fire() { @@ -320,6 +371,16 @@ fn not_fire() { }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) struct S { v: T, } @@ -328,4 +389,17 @@ struct U { v: T, w: T, x: T, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +struct S { + v: u32, +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +======= +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/manual_let_else.stderr b/tests/ui/manual_let_else.stderr index 912302b17a8f..c37b1fa901c0 100644 --- a/tests/ui/manual_let_else.stderr +++ b/tests/ui/manual_let_else.stderr @@ -1,5 +1,21 @@ error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:25:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:25:5 +======= + --> $DIR/manual_let_else.rs:24:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:25:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:25:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let v = if let Some(v_some) = g() { v_some } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { return };` @@ -7,7 +23,23 @@ LL | let v = if let Some(v_some) = g() { v_some } else { return }; = note: `-D clippy::manual-let-else` implied by `-D warnings` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:26:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:26:5 +======= + --> $DIR/manual_let_else.rs:25:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:26:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/manual_let_else.rs:26:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -24,7 +56,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:32:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:32:5 +======= + --> $DIR/manual_let_else.rs:31:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:32:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/manual_let_else.rs:32:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v) = g() { LL | | // Blocks around the identity should have no impact @@ -45,25 +93,89 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:45:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:45:9 +======= + --> $DIR/manual_let_else.rs:44:9 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:45:9 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:45:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let v = if let Some(v_some) = g() { v_some } else { continue }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { continue };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:46:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:46:9 +======= + --> $DIR/manual_let_else.rs:45:9 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:46:9 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:46:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let v = if let Some(v_some) = g() { v_some } else { break }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { break };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:50:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:50:5 +======= + --> $DIR/manual_let_else.rs:49:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:50:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:50:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let v = if let Some(v_some) = g() { v_some } else { panic!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { panic!() };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:53:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:53:5 +======= + --> $DIR/manual_let_else.rs:52:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:53:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:53:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -80,7 +192,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:60:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:60:5 +======= + --> $DIR/manual_let_else.rs:59:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:60:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:60:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -97,7 +225,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:67:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:67:5 +======= + --> $DIR/manual_let_else.rs:66:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:67:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:67:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -116,7 +260,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:77:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:77:5 +======= + --> $DIR/manual_let_else.rs:76:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:77:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:77:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -138,13 +298,45 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:87:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:87:5 +======= + --> $DIR/manual_let_else.rs:86:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:87:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:87:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let v = if let Some(v_some) = g() { v_some } else { if panic!() {} }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some(v) = g() else { if panic!() {} };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:90:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:90:5 +======= + --> $DIR/manual_let_else.rs:89:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:90:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:90:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -165,7 +357,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:99:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:99:5 +======= + --> $DIR/manual_let_else.rs:98:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:99:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:99:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -186,7 +394,23 @@ LL + } }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:108:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:108:5 +======= + --> $DIR/manual_let_else.rs:107:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:108:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:108:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let v = if let Some(v_some) = g() { LL | | v_some @@ -215,7 +439,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:125:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:125:5 +======= + --> $DIR/manual_let_else.rs:124:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:125:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:125:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let (v, w) = if let Some(v_some) = g().map(|v| (v, 42)) { LL | | v_some @@ -232,7 +472,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:132:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:132:5 +======= + --> $DIR/manual_let_else.rs:131:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= --> $DIR/manual_let_else.rs:132:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:132:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let (w, S { v }) = if let (Some(v_some), w_some) = (g().map(|_| S { v: 0 }), 0) { LL | | (w_some, v_some) @@ -249,7 +505,23 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:141:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:141:13 +======= + --> $DIR/manual_let_else.rs:140:13 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:141:13 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:141:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let $n = if let Some(v) = $e { v } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Some($n) = g() else { return };` @@ -263,10 +535,25 @@ error: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:150:5 | LL | let v = if let Variant::A(a, 0) = e() { a } else { return }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };` error: this could be rewritten as `let...else` --> $DIR/manual_let_else.rs:153:5 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let mut v = if let Variant::B(b) = e() { b } else { return }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };` @@ -352,7 +639,140 @@ LL + }; | error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else.rs:299:5 +======= + --> $DIR/manual_let_else.rs:297:5 +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(a, 0) = e() else { return };` +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(v, 0) = e() else { return };` +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) + +error: this could be rewritten as `let...else` + --> $DIR/manual_let_else.rs:152:5 +======= +>>>>>>> 26f50395b (Add `needless_if` lint) + | +LL | let mut v = if let Variant::B(b) = e() { b } else { return }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::B(mut v) = e() else { return };` + +error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:262:5 +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= + --> $DIR/manual_let_else.rs:156:5 +======= + --> $DIR/manual_let_else.rs:157:5 +>>>>>>> 26f50395b (Add `needless_if` lint) + | +LL | / let v = if let Ok(Some(Variant::B(b))) | Err(Some(Variant::A(b, _))) = nested { +LL | | b +LL | | } else { +LL | | return; +LL | | }; + | |______^ + | +help: consider writing + | +LL ~ let (Ok(Some(Variant::B(v))) | Err(Some(Variant::A(v, _)))) = nested else { +LL + return; +LL + }; + | + +error: this could be rewritten as `let...else` + --> $DIR/manual_let_else.rs:163:5 + | +LL | let v = if let Variant::A(.., a) = e() { a } else { return }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let Variant::A(.., v) = e() else { return };` + +error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:272:5 +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= + --> $DIR/manual_let_else.rs:165:5 +======= + --> $DIR/manual_let_else.rs:166:5 +>>>>>>> 26f50395b (Add `needless_if` lint) + | +LL | let w = if let (Some(v), ()) = (g(), ()) { v } else { return }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider writing: `let (Some(w), ()) = (g(), ()) else { return };` + +error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:275:5 +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +======= + --> $DIR/manual_let_else.rs:168:5 +======= + --> $DIR/manual_let_else.rs:169:5 +>>>>>>> 26f50395b (Add `needless_if` lint) + | +LL | / let w = if let Some(S { v: x }) = Some(S { v: 0 }) { +LL | | x +LL | | } else { +LL | | return; +LL | | }; + | |______^ + | +help: consider writing + | +LL ~ let Some(S { v: w }) = Some(S { v: 0 }) else { +LL + return; +LL + }; + | + +error: this could be rewritten as `let...else` + --> $DIR/manual_let_else.rs:176:5 + | +LL | / let v = if let Some(S { v: x }) = Some(S { v: 0 }) { +LL | | x +LL | | } else { +LL | | return; +LL | | }; + | |______^ + | +help: consider writing + | +LL ~ let Some(S { v }) = Some(S { v: 0 }) else { +LL + return; +LL + }; + | + +error: this could be rewritten as `let...else` + --> $DIR/manual_let_else.rs:183:5 + | +LL | / let (x, S { v }, w) = if let Some(U { v, w, x }) = None::>> { +LL | | (x, v, w) +LL | | } else { +LL | | return; +LL | | }; + | |______^ + | +help: consider writing + | +LL ~ let Some(U { v: S { v }, w, x }) = None::>> else { +LL + return; +LL + }; + | + +error: this could be rewritten as `let...else` +<<<<<<< HEAD + --> $DIR/manual_let_else.rs:296:5 +>>>>>>> f53840270 (Support struct patterns) +======= + --> $DIR/manual_let_else.rs:297:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else.rs:299:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let _ = match ff { LL | | Some(value) => value, @@ -360,5 +780,29 @@ LL | | _ => macro_call!(), LL | | }; | |______^ help: consider writing: `let Some(_) = ff else { macro_call!() };` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 26 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 26 previous errors +======= +error: aborting due to 20 previous errors +>>>>>>> 07c8c50a4 (Avoid renaming for TupleStruct with multiple arguments) +======= +error: aborting due to 22 previous errors +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +======= +error: aborting due to 23 previous errors +>>>>>>> 86d57b7bd (Support multi-binding situations as well as tuple patterns) +======= +error: aborting due to 26 previous errors +>>>>>>> f53840270 (Support struct patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 26 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/manual_let_else_match.rs b/tests/ui/manual_let_else_match.rs index 73ff69eec4ed..6e69914d053e 100644 --- a/tests/ui/manual_let_else_match.rs +++ b/tests/ui/manual_let_else_match.rs @@ -1,9 +1,31 @@ #![allow(unused_braces, unused_variables, dead_code)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::collapsible_else_if, clippy::let_unit_value, clippy::redundant_at_rest_pattern )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::collapsible_else_if, clippy::let_unit_value, clippy::redundant_rest_pattern)] +>>>>>>> 9a8347ded (New lint [`redundant_rest_pattern`]) +======= +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::manual_let_else)] // Ensure that we don't conflict with match -> if let lints #![warn(clippy::single_match_else, clippy::single_match)] @@ -73,6 +95,20 @@ fn fire() { let _value = match f { Variant::Bar(v) | Variant::Baz(v) => v, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + _ => return, + }; + + let _value = match Some(build_enum()) { + Some(Variant::Bar(v) | Variant::Baz(v)) => v, +======= +>>>>>>> ef38662d0 (Some improvements to the manual_let_else lint suggestions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) _ => return, }; diff --git a/tests/ui/manual_let_else_match.stderr b/tests/ui/manual_let_else_match.stderr index 3fd9a637605b..dd30e23f4618 100644 --- a/tests/ui/manual_let_else_match.stderr +++ b/tests/ui/manual_let_else_match.stderr @@ -64,7 +64,23 @@ LL | | }; | |______^ help: consider writing: `let (Variant::Bar(_value) | Variant::Baz(_value)) = f else { return };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_let_else_match.rs:79:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else_match.rs:79:5 +======= + --> $DIR/manual_let_else_match.rs:75:5 +>>>>>>> 0a7366897 (manual_let_else: only add () around PatKind::Or at the top level) +======= + --> $DIR/manual_let_else_match.rs:79:5 +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_let_else_match.rs:79:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let _value = match Some(build_enum()) { LL | | Some(Variant::Bar(v) | Variant::Baz(v)) => v, @@ -73,7 +89,23 @@ LL | | }; | |______^ help: consider writing: `let Some(Variant::Bar(_value) | Variant::Baz(_value)) = Some(build_enum()) else { return };` error: this could be rewritten as `let...else` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else_match.rs:85:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_let_else_match.rs:85:5 +======= + --> $DIR/manual_let_else_match.rs:81:5 +>>>>>>> 0a7366897 (manual_let_else: only add () around PatKind::Or at the top level) +======= + --> $DIR/manual_let_else_match.rs:85:5 +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/manual_let_else_match.rs:85:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / let data = match data.as_slice() { LL | | [data @ .., 0, 0, 0, 0] | [data @ .., 0, 0] | [data @ .., 0] => data, diff --git a/tests/ui/manual_slice_size_calculation.fixed b/tests/ui/manual_slice_size_calculation.fixed index 5b9629f4bc10..77c8e82a8ddd 100644 --- a/tests/ui/manual_slice_size_calculation.fixed +++ b/tests/ui/manual_slice_size_calculation.fixed @@ -1,3 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@run-rustfix //@aux-build:proc_macros.rs:proc-macro #![allow(unused)] @@ -7,6 +15,30 @@ extern crate proc_macros; use core::mem::{align_of, size_of}; use proc_macros::external; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +// run-rustfix +// aux-build:proc_macros.rs +======= +//@run-rustfix +//@aux-build:proc_macros.rs +>>>>>>> def1705a2 (Update to a compiletest-rs version that requires `//@` for commands) +#![allow(unused)] +#![warn(clippy::manual_slice_size_calculation)] + +extern crate proc_macros; + +use core::mem::{align_of, size_of}; +<<<<<<< HEAD +>>>>>>> b8fee8b50 (Add run-rustfix marker and test file) +======= +use proc_macros::external; +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { let v_i32 = Vec::::new(); @@ -23,8 +55,26 @@ fn main() { let _ = std::mem::size_of_val(s_i32); // WARNING let _ = std::mem::size_of_val(s_i32); // WARNING +<<<<<<< HEAD +<<<<<<< HEAD + let _ = std::mem::size_of_val(external!(&[1u64][..])); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = std::mem::size_of_val(external!(&[1u64][..])); + +======= +>>>>>>> b8fee8b50 (Add run-rustfix marker and test file) +======= let _ = std::mem::size_of_val(external!(&[1u64][..])); +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let _ = std::mem::size_of_val(external!(&[1u64][..])); + +>>>>>>> 615b25c20 (Rebase attempt number 2) // True negatives: let _ = size_of::() + s_i32.len(); // Ok, not a multiplication let _ = size_of::() * s_i32.partition_point(|_| true); // Ok, not len() @@ -32,9 +82,30 @@ fn main() { let _ = align_of::() * s_i32.len(); // Ok, not size_of() let _ = size_of::() * s_i32.len(); // Ok, different types +<<<<<<< HEAD +<<<<<<< HEAD + let _ = external!($s_i32.len() * size_of::()); + let _ = external!($s_i32.len()) * size_of::(); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = external!($s_i32.len() * size_of::()); + let _ = external!($s_i32.len()) * size_of::(); + +======= +>>>>>>> b8fee8b50 (Add run-rustfix marker and test file) +======= + let _ = external!($s_i32.len() * size_of::()); + let _ = external!($s_i32.len()) * size_of::(); + +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let _ = external!($s_i32.len() * size_of::()); let _ = external!($s_i32.len()) * size_of::(); +>>>>>>> 615b25c20 (Rebase attempt number 2) // False negatives: let _ = 5 * size_of::() * s_i32.len(); // Ok (MISSED OPPORTUNITY) let _ = size_of::() * 5 * s_i32.len(); // Ok (MISSED OPPORTUNITY) diff --git a/tests/ui/manual_slice_size_calculation.rs b/tests/ui/manual_slice_size_calculation.rs index 297887a9cfc8..36b79c20e220 100644 --- a/tests/ui/manual_slice_size_calculation.rs +++ b/tests/ui/manual_slice_size_calculation.rs @@ -1,5 +1,22 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@run-rustfix //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +//@run-rustfix +//@aux-build:proc_macros.rs:proc-macro +<<<<<<< HEAD +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unused)] #![warn(clippy::manual_slice_size_calculation)] diff --git a/tests/ui/manual_slice_size_calculation.stderr b/tests/ui/manual_slice_size_calculation.stderr index e09d8057a3b9..8441ab06ab52 100644 --- a/tests/ui/manual_slice_size_calculation.stderr +++ b/tests/ui/manual_slice_size_calculation.stderr @@ -1,9 +1,46 @@ error: manual slice size calculation +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/manual_slice_size_calculation.rs:16:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_slice_size_calculation.rs:16:13 +======= + --> $DIR/manual_slice_size_calculation.rs:12:13 +>>>>>>> b8fee8b50 (Add run-rustfix marker and test file) +======= + --> $DIR/manual_slice_size_calculation.rs:16:13 +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/manual_slice_size_calculation.rs:16:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = s_i32.len() * size_of::(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) + = note: `-D clippy::manual-slice-size-calculation` implied by `-D warnings` + +error: manual slice size calculation + --> $DIR/manual_slice_size_calculation.rs:17:13 + | +LL | let _ = size_of::() * s_i32.len(); // WARNING + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +<<<<<<< HEAD +======= +======= + = help: consider using std::mem::size_of_val instead +======= +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) = note: `-D clippy::manual-slice-size-calculation` implied by `-D warnings` error: manual slice size calculation @@ -11,6 +48,7 @@ error: manual slice size calculation | LL | let _ = size_of::() * s_i32.len(); // WARNING | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +>>>>>>> 0567691cb (This commit resolves issue #10655) error: manual slice size calculation --> $DIR/manual_slice_size_calculation.rs:18:13 @@ -22,6 +60,42 @@ error: manual slice size calculation --> $DIR/manual_slice_size_calculation.rs:22:13 | LL | let _ = len * size_of::(); // WARNING +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider using std::mem::size_of_val instead +>>>>>>> 4fb38cfb2 (Rename std::mem::size_of_value to std::mem::size_of_val) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) + +error: manual slice size calculation + --> $DIR/manual_slice_size_calculation.rs:23:13 + | +<<<<<<< HEAD +LL | let _ = size_of::() * s_i32.len() * 5; // WARNING + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +======= +LL | let _ = s_i32.len() * size; // WARNING +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^ + | + = help: consider using std::mem::size_of_val instead +>>>>>>> 4fb38cfb2 (Rename std::mem::size_of_value to std::mem::size_of_val) +======= + | ^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) + +error: manual slice size calculation + --> $DIR/manual_slice_size_calculation.rs:22:13 + | +LL | let _ = len * size_of::(); // WARNING +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation @@ -31,16 +105,53 @@ LL | let _ = s_i32.len() * size; // WARNING | ^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` error: manual slice size calculation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/manual_slice_size_calculation.rs:24:13 + | +LL | let _ = len * size; // WARNING + | ^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/manual_slice_size_calculation.rs:24:13 | LL | let _ = len * size; // WARNING | ^^^^^^^^^^ help: try: `std::mem::size_of_val(s_i32)` +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: manual slice size calculation --> $DIR/manual_slice_size_calculation.rs:26:13 | +<<<<<<< HEAD +<<<<<<< HEAD +LL | let _ = external!(&[1u64][..]).len() * size_of::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` +======= +<<<<<<< HEAD +<<<<<<< HEAD +LL | let _ = external!(&[1u64][..]).len() * size_of::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` +======= + = help: consider using std::mem::size_of_val instead +>>>>>>> 4fb38cfb2 (Rename std::mem::size_of_value to std::mem::size_of_val) +======= +>>>>>>> 503fd56a4 (Suggest applicable expression for manual slice size calculation lint) +======= +LL | let _ = external!(&[1u64][..]).len() * size_of::(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` +>>>>>>> 2f4f798f9 (Ignore `manual_slice_size_calculation` in code from macro expansions) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= LL | let _ = external!(&[1u64][..]).len() * size_of::(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `std::mem::size_of_val(external!(&[1u64][..]))` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: aborting due to 7 previous errors diff --git a/tests/ui/manual_try_fold.rs b/tests/ui/manual_try_fold.rs index 05c658579a5f..b3e468cf12d2 100644 --- a/tests/ui/manual_try_fold.rs +++ b/tests/ui/manual_try_fold.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 354172a18 (New lint `manual_try_fold`) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> fbb3f759e (update docs) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(clippy::unnecessary_fold, unused)] #![warn(clippy::manual_try_fold)] #![feature(try_trait_v2)] @@ -80,6 +96,16 @@ fn main() { [1, 2, 3].iter().try_fold(0i32, |sum, i| sum.checked_add(*i)).unwrap(); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 24039ca2c (Add msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::msrv = "1.26.0"] fn msrv_too_low() { @@ -96,3 +122,14 @@ fn msrv_juust_right() { .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) .unwrap(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 354172a18 (New lint `manual_try_fold`) +======= +>>>>>>> 24039ca2c (Add msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/manual_try_fold.stderr b/tests/ui/manual_try_fold.stderr index f1bb97c6d0f3..d21f67cf9d08 100644 --- a/tests/ui/manual_try_fold.stderr +++ b/tests/ui/manual_try_fold.stderr @@ -1,3 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: usage of `Iterator::fold` on a type that implements `Try` --> $DIR/manual_try_fold.rs:59:10 | @@ -25,4 +33,50 @@ LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` error: aborting due to 4 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: you seem to be using `Iterator::fold` on a type that implements `Try` +======= +error: usage of `Iterator::fold` on a type that implements `Try` +>>>>>>> cb5d7e344 (address comments) + --> $DIR/manual_try_fold.rs:61:10 + | +LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` + | + = note: `-D clippy::manual-try-fold` implied by `-D warnings` + +error: usage of `Iterator::fold` on a type that implements `Try` + --> $DIR/manual_try_fold.rs:65:10 + | +LL | .fold(NotOption(0i32, 0i32), |sum, i| NotOption(0i32, 0i32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(..., |sum, i| ...)` + +error: usage of `Iterator::fold` on a type that implements `Try` + --> $DIR/manual_try_fold.rs:68:10 + | +LL | .fold(NotOptionButWorse(0i32), |sum, i| NotOptionButWorse(0i32)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` + +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 3 previous errors +>>>>>>> 354172a18 (New lint `manual_try_fold`) +======= +error: you seem to be using `Iterator::fold` on a type that implements `Try` +======= +error: usage of `Iterator::fold` on a type that implements `Try` +>>>>>>> cb5d7e344 (address comments) + --> $DIR/manual_try_fold.rs:98:10 + | +LL | .fold(Some(0i32), |sum, i| sum?.checked_add(*i)) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use `try_fold` instead: `try_fold(0i32, |sum, i| ...)` + +error: aborting due to 4 previous errors +>>>>>>> 24039ca2c (Add msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/map_unwrap_or.rs b/tests/ui/map_unwrap_or.rs index bb36cb2c598b..f2c47fe3a2d3 100644 --- a/tests/ui/map_unwrap_or.rs +++ b/tests/ui/map_unwrap_or.rs @@ -99,6 +99,16 @@ fn msrv_1_41() { let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c60222dc1 (changed the msrv to 1.70 to suggest `is_some_and`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::msrv = "1.69"] fn msrv_1_69() { let opt: Option = Some(1); @@ -113,6 +123,17 @@ fn msrv_1_70() { let _ = opt.map(|x| x > 5).unwrap_or(false); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 9d58a4262 ([`map_unwrap_or`]: don't lint when referenced variable is moved) +======= +>>>>>>> c60222dc1 (changed the msrv to 1.70 to suggest `is_some_and`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod issue_10579 { // Different variations of the same issue. fn v1() { diff --git a/tests/ui/map_unwrap_or.stderr b/tests/ui/map_unwrap_or.stderr index 5b3c61acf747..b4a5c5f2ed8a 100644 --- a/tests/ui/map_unwrap_or.stderr +++ b/tests/ui/map_unwrap_or.stderr @@ -164,6 +164,16 @@ error: called `map().unwrap_or_else()` on a `Result` value. This can be do LL | let _ = res.map(|x| x + 1).unwrap_or_else(|_e| 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or_else(|_e| 0, |x| x + 1)` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c60222dc1 (changed the msrv to 1.70 to suggest `is_some_and`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: called `map().unwrap_or()` on an `Option` value. This can be done more directly by calling `map_or(, )` instead --> $DIR/map_unwrap_or.rs:106:13 | @@ -189,4 +199,16 @@ LL + let _ = opt.is_some_and(|x| x > 5); | error: aborting due to 15 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 13 previous errors +>>>>>>> 9b7d8d1dc (suggests `is_some_and` over `map().unwrap_or(false)`) +======= +>>>>>>> c60222dc1 (changed the msrv to 1.70 to suggest `is_some_and`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/match_on_vec_items.rs b/tests/ui/match_on_vec_items.rs index cf9c279cd2f1..985a2759f13a 100644 --- a/tests/ui/match_on_vec_items.rs +++ b/tests/ui/match_on_vec_items.rs @@ -1,5 +1,25 @@ #![warn(clippy::match_on_vec_items)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::redundant_at_rest_pattern, clippy::useless_vec)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::redundant_at_rest_pattern, clippy::useless_vec)] +======= +#![allow(clippy::useless_vec)] +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +#![allow(clippy::redundant_rest_pattern, clippy::useless_vec)] +>>>>>>> 9a8347ded (New lint [`redundant_rest_pattern`]) +======= +#![allow(clippy::redundant_at_rest_pattern, clippy::useless_vec)] +>>>>>>> e9ced1251 (Rename the lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::redundant_at_rest_pattern, clippy::useless_vec)] +>>>>>>> 615b25c20 (Rebase attempt number 2) fn match_with_wildcard() { let arr = vec![0, 1, 2, 3]; diff --git a/tests/ui/match_same_arms.rs b/tests/ui/match_same_arms.rs index fad6a7db988c..3a081c680357 100644 --- a/tests/ui/match_same_arms.rs +++ b/tests/ui/match_same_arms.rs @@ -59,6 +59,16 @@ macro_rules! m { (foo) => {}; (bar) => {}; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! foo { () => { 1 @@ -69,6 +79,17 @@ macro_rules! bar { 1 }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { let x = 0; @@ -86,6 +107,16 @@ fn main() { let _ = match 0 { 0 => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) m!(foo); 0 }, @@ -98,6 +129,17 @@ fn main() { let _ = match 0 { 0 => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +>>>>>>> 535117074 (Slightly refactor constant evaluation and add detection for empty macro expansion and `cfg`ed statements.) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let mut x = 0; #[cfg(not_enabled)] { @@ -123,6 +165,16 @@ fn main() { }, _ => 0, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = match 0 { 0 => foo!(), @@ -135,4 +187,15 @@ fn main() { 1 => cfg!(also_not_enabled), _ => false, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 0b3c2ed81 (Search for inactive `cfg` attributes and empty macro expansion through) +======= +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/match_same_arms2.stderr b/tests/ui/match_same_arms2.stderr index a73481875738..9599faa9a5ff 100644 --- a/tests/ui/match_same_arms2.stderr +++ b/tests/ui/match_same_arms2.stderr @@ -194,7 +194,23 @@ LL | Some(Bar { x: 0, y: 5, .. }) => 1, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this match arm has an identical body to another arm +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/match_same_arms2.rs:246:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/match_same_arms2.rs:246:9 +======= + --> $DIR/match_same_arms2.rs:245:9 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/match_same_arms2.rs:246:9 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/match_same_arms2.rs:246:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1 => cfg!(not_enable), | -^^^^^^^^^^^^^^^^^^^^ @@ -203,7 +219,23 @@ LL | 1 => cfg!(not_enable), | = help: or try changing either arm body note: other arm here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/match_same_arms2.rs:245:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/match_same_arms2.rs:245:9 +======= + --> $DIR/match_same_arms2.rs:244:9 +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= + --> $DIR/match_same_arms2.rs:245:9 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/match_same_arms2.rs:245:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 0 => cfg!(not_enable), | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/mem_forget.stderr b/tests/ui/mem_forget.stderr index 8004b2aa8db7..786f5505cfb1 100644 --- a/tests/ui/mem_forget.stderr +++ b/tests/ui/mem_forget.stderr @@ -4,7 +4,27 @@ error: usage of `mem::forget` on `Drop` type LL | memstuff::forget(six); | ^^^^^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD = note: argument has type `std::sync::Arc` +======= +<<<<<<< HEAD +<<<<<<< HEAD + = note: argument has type `std::sync::Arc` +======= +note: argument has type `std::sync::Arc` + --> $DIR/mem_forget.rs:14:22 + | +LL | memstuff::forget(six); + | ^^^ +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= + = note: argument has type `std::sync::Arc` +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: argument has type `std::sync::Arc` +>>>>>>> 615b25c20 (Rebase attempt number 2) = note: `-D clippy::mem-forget` implied by `-D warnings` error: usage of `mem::forget` on `Drop` type @@ -13,7 +33,27 @@ error: usage of `mem::forget` on `Drop` type LL | std::mem::forget(seven); | ^^^^^^^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = note: argument has type `std::rc::Rc` +======= +<<<<<<< HEAD +<<<<<<< HEAD + = note: argument has type `std::rc::Rc` +======= +note: argument has type `std::rc::Rc` + --> $DIR/mem_forget.rs:17:22 + | +LL | std::mem::forget(seven); + | ^^^^^ +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= = note: argument has type `std::rc::Rc` +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: argument has type `std::rc::Rc` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: usage of `mem::forget` on `Drop` type --> $DIR/mem_forget.rs:20:5 @@ -21,15 +61,61 @@ error: usage of `mem::forget` on `Drop` type LL | forgetSomething(eight); | ^^^^^^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = note: argument has type `std::vec::Vec` +======= +<<<<<<< HEAD +<<<<<<< HEAD = note: argument has type `std::vec::Vec` +======= +note: argument has type `std::vec::Vec` + --> $DIR/mem_forget.rs:20:21 + | +LL | forgetSomething(eight); + | ^^^^^ +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= + = note: argument has type `std::vec::Vec` +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: argument has type `std::vec::Vec` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: usage of `mem::forget` on type with `Drop` fields --> $DIR/mem_forget.rs:23:5 | LL | std::mem::forget(string); | ^^^^^^^^^^^^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: argument has type `std::string::String` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: argument has type `std::string::String` +======= +>>>>>>> d8d59965f (Lint `mem_forget` if fields are `Drop`) +======= + | +<<<<<<< HEAD +note: argument has type `std::string::String` + --> $DIR/mem_forget.rs:23:22 + | +LL | std::mem::forget(string); + | ^^^^^^ +>>>>>>> b6f194b48 (move to `drop_forget_ref`) +======= + = note: argument has type `std::string::String` +>>>>>>> a5ae9044f (make note less verbose) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= | = note: argument has type `std::string::String` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: aborting due to 4 previous errors diff --git a/tests/ui/min_ident_chars.rs b/tests/ui/min_ident_chars.rs index 0fab224a29d3..454b9684a14e 100644 --- a/tests/ui/min_ident_chars.rs +++ b/tests/ui/min_ident_chars.rs @@ -1,5 +1,27 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro #![allow(irrefutable_let_patterns, nonstandard_style, unused)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5bd97ac17 (Update tests) +//@aux-build:proc_macros.rs:proc-macro +#![allow(irrefutable_let_patterns, nonstandard_style, unused)] +======= +//@aux-build:proc_macros.rs +<<<<<<< HEAD +#![allow(nonstandard_style, unused)] +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +#![allow(irrefutable_let_patterns, nonstandard_style, unused)] +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +#![allow(irrefutable_let_patterns, nonstandard_style, unused)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::min_ident_chars)] extern crate proc_macros; @@ -14,10 +36,31 @@ struct A { struct B(u32); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) struct O { o: u32, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) struct i; enum C { @@ -41,6 +84,16 @@ fn main() { let w = 1; // Ok, not this one // let i = 1; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 243943ff5 (make it work for locals as well) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let j = 1; let n = 1; let z = 1; @@ -67,6 +120,29 @@ fn main() { for j in 0..1000 {} for _ in 0..10 {} +<<<<<<< HEAD +======= +<<<<<<< HEAD + + for j in 0..1000 {} + for _ in 0..10 {} +<<<<<<< HEAD +======= + let jz = 1; + let nz = 1; + let zx = 1; + let yz = 1; + let zz = 1; +======= +>>>>>>> 243943ff5 (make it work for locals as well) + + for j in 0..1000 {} +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do not lint code from external macros external! { for j in 0..1000 {} } @@ -78,6 +154,28 @@ fn main() { } fn b() {} +<<<<<<< HEAD +<<<<<<< HEAD +fn wrong_pythagoras(a: f32, b: f32) -> f32 { + a * a + a * b +} +======= +<<<<<<< HEAD +<<<<<<< HEAD +fn wrong_pythagoras(a: f32, b: f32) -> f32 { + a * a + a * b +} +======= +fn owo() {} +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +fn wrong_pythagoras(a: f32, b: f32) -> f32 { + a * a + a * b +} +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= fn wrong_pythagoras(a: f32, b: f32) -> f32 { a * a + a * b } +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/min_ident_chars.stderr b/tests/ui/min_ident_chars.stderr index 4dff6588bb18..53802c78c2b1 100644 --- a/tests/ui/min_ident_chars.stderr +++ b/tests/ui/min_ident_chars.stderr @@ -31,7 +31,23 @@ LL | struct B(u32); | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/min_ident_chars.rs:17:8 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 243943ff5 (make it work for locals as well) + --> $DIR/min_ident_chars.rs:18:8 +======= + --> $DIR/min_ident_chars.rs:17:8 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/min_ident_chars.rs:17:8 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | struct O { | ^ @@ -43,31 +59,123 @@ LL | o: u32, | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:23:6 +======= +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:24:6 +<<<<<<< HEAD +======= + --> $DIR/min_ident_chars.rs:20:6 +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +>>>>>>> 243943ff5 (make it work for locals as well) +======= + --> $DIR/min_ident_chars.rs:23:6 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/min_ident_chars.rs:23:6 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | enum C { | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:24:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:25:5 +======= + --> $DIR/min_ident_chars.rs:21:5 +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + --> $DIR/min_ident_chars.rs:25:5 +>>>>>>> 243943ff5 (make it work for locals as well) +======= --> $DIR/min_ident_chars.rs:24:5 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/min_ident_chars.rs:24:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | D, | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:25:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:26:5 +======= + --> $DIR/min_ident_chars.rs:22:5 +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + --> $DIR/min_ident_chars.rs:26:5 +>>>>>>> 243943ff5 (make it work for locals as well) +======= + --> $DIR/min_ident_chars.rs:25:5 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/min_ident_chars.rs:25:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | E, | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:26:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:27:5 +======= + --> $DIR/min_ident_chars.rs:23:5 +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + --> $DIR/min_ident_chars.rs:27:5 +>>>>>>> 243943ff5 (make it work for locals as well) +======= --> $DIR/min_ident_chars.rs:26:5 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/min_ident_chars.rs:26:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | F, | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:50:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:51:9 +======= + --> $DIR/min_ident_chars.rs:50:9 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/min_ident_chars.rs:50:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let h = 1; | ^ @@ -157,11 +265,137 @@ LL | let o = O { o }; | ^ error: this ident consists of a single char +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:80:4 +======= +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:81:4 +<<<<<<< HEAD +======= + --> $DIR/min_ident_chars.rs:31:5 +======= + --> $DIR/min_ident_chars.rs:51:9 +>>>>>>> 243943ff5 (make it work for locals as well) + | +LL | let h = 1; + | ^ + +error: this ident consists of a single char +<<<<<<< HEAD + --> $DIR/min_ident_chars.rs:58:4 +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= + --> $DIR/min_ident_chars.rs:52:9 + | +LL | let e = 2; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:53:9 + | +LL | let l = 3; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:54:9 + | +LL | let l = 4; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:55:9 + | +LL | let o = 6; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:59:10 + | +LL | let (h, o, w) = (1, 2, 3); + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:59:13 + | +LL | let (h, o, w) = (1, 2, 3); + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:60:10 + | +LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:60:14 + | +LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:60:17 + | +LL | for (a, (r, e)) in (0..1000).enumerate().enumerate() {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:62:16 + | +LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:62:19 + | +LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:62:29 + | +LL | while let (d, o, _i, n, g) = (true, true, false, false, true) {} + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:66:9 + | +LL | let o = 1; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:67:9 + | +LL | let o = O { o }; + | ^ + +error: this ident consists of a single char + --> $DIR/min_ident_chars.rs:80:4 +>>>>>>> 243943ff5 (make it work for locals as well) +======= +>>>>>>> 95d1bff22 (add to tests and configuration) +======= + --> $DIR/min_ident_chars.rs:80:4 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/min_ident_chars.rs:80:4 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | fn b() {} | ^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: this ident consists of a single char --> $DIR/min_ident_chars.rs:81:21 | @@ -175,4 +409,19 @@ LL | fn wrong_pythagoras(a: f32, b: f32) -> f32 { | ^ error: aborting due to 29 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 11 previous errors +>>>>>>> 7cdd87ca4 (ignore generics and allow arbitrary threshold) +======= +error: aborting due to 27 previous errors +>>>>>>> 243943ff5 (make it work for locals as well) +======= +>>>>>>> 95d1bff22 (add to tests and configuration) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/missing_const_for_fn/cant_be_const.rs b/tests/ui/missing_const_for_fn/cant_be_const.rs index 06e053524798..af3885431f1e 100644 --- a/tests/ui/missing_const_for_fn/cant_be_const.rs +++ b/tests/ui/missing_const_for_fn/cant_be_const.rs @@ -126,7 +126,22 @@ with_span! { fn dont_check_in_proc_macro() {} } +<<<<<<< HEAD +<<<<<<< HEAD // Do not lint `String` has `Vec`, which cannot be dropped in const contexts +======= +<<<<<<< HEAD +<<<<<<< HEAD +// Do not lint `String` has `Vec`, which cannot be dropped in const contexts +======= +>>>>>>> e24fc9af2 (Fix `missing_const_for_fn` not checking `~const Destruct`) +======= +// Do not lint `String` has `Vec`, which cannot be dropped in const contexts +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +// Do not lint `String` has `Vec`, which cannot be dropped in const contexts +>>>>>>> 615b25c20 (Rebase attempt number 2) fn a(this: String) {} enum A { @@ -134,9 +149,29 @@ enum A { N, } +<<<<<<< HEAD +<<<<<<< HEAD +// Same here. +fn b(this: A) {} + +======= +<<<<<<< HEAD +<<<<<<< HEAD +// Same here. +fn b(this: A) {} + +<<<<<<< HEAD +======= // Same here. fn b(this: A) {} +>>>>>>> 5692677b3 (cleanup spaghetti code) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +// Same here. +fn b(this: A) {} + +>>>>>>> 615b25c20 (Rebase attempt number 2) // Minimized version of `a`. fn c(this: Vec) {} @@ -156,6 +191,16 @@ impl Issue10617 { self.0 } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 9bc6e114e (add non-test-case for suggesting const on functions accessing union fields) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) union U { f: u32, @@ -165,3 +210,20 @@ union U { fn h(u: U) -> u32 { unsafe { u.f } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +fn b(this: A) {} +>>>>>>> e24fc9af2 (Fix `missing_const_for_fn` not checking `~const Destruct`) +======= +fn c(this: Vec) {} +>>>>>>> 0e233492d (use trait solver instead; created spaghetti code) +======= +>>>>>>> 5692677b3 (cleanup spaghetti code) +======= +>>>>>>> 9bc6e114e (add non-test-case for suggesting const on functions accessing union fields) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/missing_fields_in_debug.rs b/tests/ui/missing_fields_in_debug.rs index c156d394ecea..454b070fa0dd 100644 --- a/tests/ui/missing_fields_in_debug.rs +++ b/tests/ui/missing_fields_in_debug.rs @@ -97,12 +97,164 @@ impl fmt::Debug for MultiExprDebugImpl { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +enum SingleVariantEnumUnnamed { + A(u8), +} + +// ok +impl fmt::Debug for SingleVariantEnumUnnamed { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + } + } +} + +enum MultiVariantEnum { + A(u8), + B { a: u8, b: String }, + C, +} + +impl fmt::Debug for MultiVariantEnum { + // match arm Self::B ignores `b` + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + Self::B { a, b } => formatter.debug_struct("B").field("a", &a).finish(), + Self::C => formatter.debug_struct("C").finish(), + } + } +} + +enum MultiVariantEnumOk { + A(u8), + B { a: u8, b: String }, + C, +} + +// ok +impl fmt::Debug for MultiVariantEnumOk { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + Self::B { a, b } => formatter.debug_struct("B").field("a", &a).field("b", &b).finish(), + Self::C => formatter.debug_struct("C").finish(), + } + } +} + +enum MultiVariantEnumNonExhaustive { + A(u8), + B { a: u8, b: String }, + C, +} + +// ok +impl fmt::Debug for MultiVariantEnumNonExhaustive { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + Self::B { a, b } => formatter.debug_struct("B").field("b", &b).finish_non_exhaustive(), + Self::C => formatter.debug_struct("C").finish(), + } + } +} + +enum MultiVariantRest { + A(u8), + B { a: u8, b: String }, + C, +} + +impl fmt::Debug for MultiVariantRest { + // `a` field ignored due to rest pattern + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish(), + Self::C => formatter.debug_struct("C").finish(), + } + } +} + +enum MultiVariantRestNonExhaustive { + A(u8), + B { a: u8, b: String }, + C, +} + +// ok +impl fmt::Debug for MultiVariantRestNonExhaustive { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish_non_exhaustive(), + Self::C => formatter.debug_struct("C").finish(), + } + } +} + +enum Wildcard { + A(u8), + B(String), +} + +// ok +impl fmt::Debug for Wildcard { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match self { + Self::A(n) => formatter.debug_tuple("A").field(&n).finish(), + _ => todo!(), + } + } +} + +enum Empty {} + +// ok +impl fmt::Debug for Empty { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + match *self {} + } +} + +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Debug)] struct DerivedStruct { a: u8, b: i32, } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +#[derive(Debug)] +enum DerivedEnum { + A(i32), + B { a: String }, +} + +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // /~https://github.com/rust-lang/rust-clippy/pull/10616#discussion_r1166846953 struct Inner { diff --git a/tests/ui/missing_fields_in_debug.stderr b/tests/ui/missing_fields_in_debug.stderr index ef9d02abab7d..ee324568ba17 100644 --- a/tests/ui/missing_fields_in_debug.stderr +++ b/tests/ui/missing_fields_in_debug.stderr @@ -69,5 +69,61 @@ LL | b: String, = help: consider including all fields in this `Debug` impl = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields +<<<<<<< HEAD +<<<<<<< HEAD error: aborting due to 3 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 3 previous errors +======= +error: manual `Debug` impl does not include all fields + --> $DIR/missing_fields_in_debug.rs:119:1 + | +LL | / impl fmt::Debug for MultiVariantEnum { +LL | | // match arm Self::B ignores `b` +LL | | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { +LL | | match self { +... | +LL | | } +LL | | } + | |_^ + | +note: the field referenced by this binding is unused + --> $DIR/missing_fields_in_debug.rs:124:26 + | +LL | Self::B { a, b } => formatter.debug_struct("B").field("a", &a).finish(), + | ^ + = help: consider including all fields in this `Debug` impl + = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields + +error: manual `Debug` impl does not include all fields + --> $DIR/missing_fields_in_debug.rs:170:1 + | +LL | / impl fmt::Debug for MultiVariantRest { +LL | | // `a` field ignored due to rest pattern +LL | | fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { +LL | | match self { +... | +LL | | } +LL | | } + | |_^ + | +note: more unused fields here due to rest pattern `..` + --> $DIR/missing_fields_in_debug.rs:175:13 + | +LL | Self::B { b, .. } => formatter.debug_struct("B").field("b", &b).finish(), + | ^^^^^^^^^^^^^^^^^ + = help: consider including all fields in this `Debug` impl + = help: consider calling `.finish_non_exhaustive()` if you intend to ignore fields + +error: aborting due to 5 previous errors +>>>>>>> f74ec6b1b (new lint: `missing_field_in_debug`) +======= +error: aborting due to 3 previous errors +>>>>>>> a859b0e6d (don't lint enums, update note in lint description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: aborting due to 3 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/missing_panics_doc.rs b/tests/ui/missing_panics_doc.rs index 0e1533fc1ab1..15f4d59c4888 100644 --- a/tests/ui/missing_panics_doc.rs +++ b/tests/ui/missing_panics_doc.rs @@ -1,12 +1,33 @@ //@aux-build:macro_rules.rs #![warn(clippy::missing_panics_doc)] #![allow(clippy::option_map_unit_fn, clippy::unnecessary_literal_unwrap)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[macro_use] extern crate macro_rules; use macro_rules::macro_with_panic; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +======= +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} /// This needs to be documented @@ -176,6 +197,16 @@ pub mod issue10240 { *v.last().expect("passed an empty thing") } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn from_external_macro_should_not_lint() { macro_with_panic!() @@ -191,3 +222,14 @@ fn from_declared_macro_should_lint_at_macrosite() { // Not here. some_macro_that_panics!() } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 73cd2cde8 (merge test) +======= +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/missing_panics_doc.stderr b/tests/ui/missing_panics_doc.stderr index 3dbe2dfbd88f..eace34979a93 100644 --- a/tests/ui/missing_panics_doc.stderr +++ b/tests/ui/missing_panics_doc.stderr @@ -72,76 +72,284 @@ LL | assert_ne!(x, 0); | ^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/missing_panics_doc.rs:151:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:151:5 +======= + --> $DIR/missing_panics_doc.rs:158:5 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:151:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:151:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn option_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:153:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:153:9 +======= + --> $DIR/missing_panics_doc.rs:160:9 +>>>>>>> 73cd2cde8 (merge test) +======= --> $DIR/missing_panics_doc.rs:153:9 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:153:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | o.unwrap() | ^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:156:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:156:5 +======= + --> $DIR/missing_panics_doc.rs:163:5 +>>>>>>> 73cd2cde8 (merge test) +======= --> $DIR/missing_panics_doc.rs:156:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:156:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn option_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:158:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/missing_panics_doc.rs:158:9 +======= + --> $DIR/missing_panics_doc.rs:165:9 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:158:9 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:158:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | o.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:161:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:161:5 +======= + --> $DIR/missing_panics_doc.rs:168:5 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:161:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/missing_panics_doc.rs:161:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn result_unwrap(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/missing_panics_doc.rs:163:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:163:9 +======= + --> $DIR/missing_panics_doc.rs:170:9 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:163:9 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:163:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | res.unwrap() | ^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:166:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:166:5 +======= + --> $DIR/missing_panics_doc.rs:173:5 +>>>>>>> 73cd2cde8 (merge test) +======= --> $DIR/missing_panics_doc.rs:166:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:166:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn result_expect(v: &[T]) -> &T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:168:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:168:9 +======= + --> $DIR/missing_panics_doc.rs:175:9 +>>>>>>> 73cd2cde8 (merge test) +======= --> $DIR/missing_panics_doc.rs:168:9 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:168:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | res.expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:171:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/missing_panics_doc.rs:171:5 +======= + --> $DIR/missing_panics_doc.rs:178:5 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:171:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:171:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn last_unwrap(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:172:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:172:10 +======= + --> $DIR/missing_panics_doc.rs:179:10 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:172:10 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/missing_panics_doc.rs:172:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | *v.last().unwrap() | ^^^^^^^^^^^^^^^^^ error: docs for function which may panic missing `# Panics` section +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/missing_panics_doc.rs:175:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:175:5 +======= + --> $DIR/missing_panics_doc.rs:182:5 +>>>>>>> 73cd2cde8 (merge test) +======= + --> $DIR/missing_panics_doc.rs:175:5 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:175:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | pub fn last_expect(v: &[u32]) -> u32 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: first possible panic found here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:176:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/missing_panics_doc.rs:176:10 +======= + --> $DIR/missing_panics_doc.rs:183:10 +>>>>>>> 73cd2cde8 (merge test) +======= --> $DIR/missing_panics_doc.rs:176:10 +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/missing_panics_doc.rs:176:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | *v.last().expect("passed an empty thing") | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 12 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 12 previous errors +======= +error: aborting due to 13 previous errors +>>>>>>> 73cd2cde8 (merge test) +======= +error: aborting due to 12 previous errors +>>>>>>> a6346d7c9 (`missing_panics_in_doc` bless test and add additional macro testcase) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 12 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/needless_arbitrary_self_type_unfixable.rs b/tests/ui/needless_arbitrary_self_type_unfixable.rs index 876f16a3854d..c64ad452cbb5 100644 --- a/tests/ui/needless_arbitrary_self_type_unfixable.rs +++ b/tests/ui/needless_arbitrary_self_type_unfixable.rs @@ -1,4 +1,16 @@ //@aux-build:proc_macro_attr.rs:proc-macro +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +// Flaky test, see /~https://github.com/rust-lang/rust/issues/113585. +//@ignore-32bit +//@ignore-64bit +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::needless_arbitrary_self_type)] diff --git a/tests/ui/needless_collect.fixed b/tests/ui/needless_collect.fixed index 0f0aaad17b45..f513c7350deb 100644 --- a/tests/ui/needless_collect.fixed +++ b/tests/ui/needless_collect.fixed @@ -70,11 +70,32 @@ fn main() { bar((0..10).collect::>(), (0..10)); baz((0..10), (), ('a'..='z')) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let values = [1, 2, 3, 4]; let mut out = vec![]; values.iter().cloned().map(|x| out.push(x)).collect::>(); let _y = values.iter().cloned().map(|x| out.push(x)).collect::>(); // this is fine +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 84f89f30e (enhance `needless_collect`) +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn foo(_: impl IntoIterator) {} diff --git a/tests/ui/needless_collect.rs b/tests/ui/needless_collect.rs index 4f48f24b17b8..f05c0e567f54 100644 --- a/tests/ui/needless_collect.rs +++ b/tests/ui/needless_collect.rs @@ -70,11 +70,32 @@ fn main() { bar((0..10).collect::>(), (0..10).collect::>()); baz((0..10), (), ('a'..='z').collect::>()) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let values = [1, 2, 3, 4]; let mut out = vec![]; values.iter().cloned().map(|x| out.push(x)).collect::>(); let _y = values.iter().cloned().map(|x| out.push(x)).collect::>(); // this is fine +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 84f89f30e (enhance `needless_collect`) +======= +>>>>>>> 974900b50 (Split `for_loops` tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn foo(_: impl IntoIterator) {} diff --git a/tests/ui/needless_collect_indirect.rs b/tests/ui/needless_collect_indirect.rs index d3d856c2c659..79b15b7f52eb 100644 --- a/tests/ui/needless_collect_indirect.rs +++ b/tests/ui/needless_collect_indirect.rs @@ -1,5 +1,20 @@ #![allow(clippy::uninlined_format_args, clippy::useless_vec)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_if, clippy::uninlined_format_args)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_if, clippy::uninlined_format_args)] +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +#![allow(clippy::needless_if, clippy::uninlined_format_args)] +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_if, clippy::uninlined_format_args)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::needless_collect)] use std::collections::{BinaryHeap, HashMap, HashSet, LinkedList, VecDeque}; diff --git a/tests/ui/needless_else.fixed b/tests/ui/needless_else.fixed index 06a16162790c..a048d3ed7760 100644 --- a/tests/ui/needless_else.fixed +++ b/tests/ui/needless_else.fixed @@ -12,10 +12,31 @@ macro_rules! mac { }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! empty_expansion { () => {}; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { let b = std::hint::black_box(true); @@ -41,6 +62,16 @@ fn main() { // Do not lint because inside a macro mac!(b); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if b { println!("Foobar"); @@ -54,4 +85,15 @@ fn main() { } else { empty_expansion!(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_else.rs b/tests/ui/needless_else.rs index 728032c47a66..fdda7f6b4d5b 100644 --- a/tests/ui/needless_else.rs +++ b/tests/ui/needless_else.rs @@ -12,10 +12,31 @@ macro_rules! mac { }; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! empty_expansion { () => {}; } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() { let b = std::hint::black_box(true); @@ -42,6 +63,16 @@ fn main() { // Do not lint because inside a macro mac!(b); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if b { println!("Foobar"); @@ -55,4 +86,15 @@ fn main() { } else { empty_expansion!(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_else.stderr b/tests/ui/needless_else.stderr index 49cd78501eac..b686daf2cf0f 100644 --- a/tests/ui/needless_else.stderr +++ b/tests/ui/needless_else.stderr @@ -1,5 +1,27 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: this `else` branch is empty --> $DIR/needless_else.rs:24:7 +======= +<<<<<<< HEAD +error: this else branch is empty +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +error: this `else` branch is empty + --> $DIR/needless_else.rs:24:7 +<<<<<<< HEAD +======= + --> $DIR/needless_else.rs:20:7 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= + --> $DIR/needless_else.rs:24:7 +>>>>>>> 021b7398e (Ignore #[cfg]'d out code in needless_else) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else { | _______^ diff --git a/tests/ui/needless_if.fixed b/tests/ui/needless_if.fixed index 6001c9e93011..e9d1b0ae9ca1 100644 --- a/tests/ui/needless_if.fixed +++ b/tests/ui/needless_if.fixed @@ -1,16 +1,69 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro #![feature(let_chains)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5bd97ac17 (Update tests) +//@aux-build:proc_macros.rs:proc-macro +#![feature(let_chains)] +======= +//@aux-build:proc_macros.rs +<<<<<<< HEAD +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +#![feature(let_chains)] +>>>>>>> 59bca098f (don't lint on `if let`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +#![feature(let_chains)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::blocks_in_if_conditions, clippy::if_same_then_else, clippy::ifs_same_cond, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::let_unit_value, clippy::needless_else, clippy::no_effect, clippy::nonminimal_bool, +<<<<<<< HEAD +<<<<<<< HEAD + clippy::short_circuit_statement, + clippy::unnecessary_operation, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::short_circuit_statement, + clippy::unnecessary_operation, +======= + clippy::needless_else, + clippy::no_effect, +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +>>>>>>> 59bca098f (don't lint on `if let`) +======= + clippy::short_circuit_statement, + clippy::unnecessary_operation, +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= clippy::short_circuit_statement, clippy::unnecessary_operation, +>>>>>>> 615b25c20 (Rebase attempt number 2) unused )] #![warn(clippy::needless_if)] @@ -18,7 +71,42 @@ extern crate proc_macros; use proc_macros::{external, with_span}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +fn maybe_side_effect() -> bool { + true +} + +fn main() { + // Lint + + // Do not remove the condition + maybe_side_effect(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +fn main() { + // Lint + (true); +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +fn no_side_effects() -> bool { + true +} + +fn has_side_effects(a: &mut u32) -> bool { + *a = 1; +======= fn maybe_side_effect() -> bool { +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) true } @@ -26,18 +114,97 @@ fn main() { // Lint // Do not remove the condition +<<<<<<< HEAD + no_side_effects(); + let mut x = 0; + has_side_effects(&mut x); + assert_eq!(x, 1); +>>>>>>> 59bca098f (don't lint on `if let`) +======= maybe_side_effect(); +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do not lint if (true) { } else { } +<<<<<<< HEAD +<<<<<<< HEAD ({ return; }); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + ({ + return; + }); +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + { + return; + }; +>>>>>>> 59bca098f (don't lint on `if let`) +======= + ({ + return; + }); +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + ({ + return; + }); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do not lint if `else if` is present if (true) { } else if (true) { } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // Do not lint `if let` or let chains + if let true = true {} + if let true = true && true {} + if true && let true = true {} + // Can lint nested `if let`s + ({ + if let true = true && true { true } else { false } + } && true); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // Ensure clippy does not bork this up, other cases should be added + { + return; + }; +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + // Do not lint if any `let` is present + if let true = true {} + if let true = true && true {} + if true && let true = true {} +<<<<<<< HEAD + if { if let true = true && true { true } else { false } } && true {} +>>>>>>> 59bca098f (don't lint on `if let`) +======= + if { + if let true = true && true { true } else { false } + } && true + {} +>>>>>>> d989f432a (Update needless_if.fixed) +======= // Do not lint `if let` or let chains if let true = true {} if let true = true && true {} @@ -46,11 +213,25 @@ fn main() { ({ if let true = true && true { true } else { false } } && true); +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) external! { if (true) {} } with_span! { span if (true) {} } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if true { // comment @@ -89,4 +270,15 @@ fn main() { true; let () = if maybe_side_effect() {}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_if.rs b/tests/ui/needless_if.rs index c6be4766dd8a..63700c8c06c2 100644 --- a/tests/ui/needless_if.rs +++ b/tests/ui/needless_if.rs @@ -1,16 +1,69 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro #![feature(let_chains)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5bd97ac17 (Update tests) +//@aux-build:proc_macros.rs:proc-macro +#![feature(let_chains)] +======= +//@aux-build:proc_macros.rs +<<<<<<< HEAD +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +#![feature(let_chains)] +>>>>>>> 59bca098f (don't lint on `if let`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +#![feature(let_chains)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::blocks_in_if_conditions, clippy::if_same_then_else, clippy::ifs_same_cond, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::let_unit_value, clippy::needless_else, clippy::no_effect, clippy::nonminimal_bool, +<<<<<<< HEAD +<<<<<<< HEAD + clippy::short_circuit_statement, + clippy::unnecessary_operation, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::short_circuit_statement, + clippy::unnecessary_operation, +======= + clippy::needless_else, + clippy::no_effect, +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +>>>>>>> 59bca098f (don't lint on `if let`) +======= clippy::short_circuit_statement, clippy::unnecessary_operation, +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::short_circuit_statement, + clippy::unnecessary_operation, +>>>>>>> 615b25c20 (Rebase attempt number 2) unused )] #![warn(clippy::needless_if)] @@ -18,7 +71,29 @@ extern crate proc_macros; use proc_macros::{external, with_span}; +<<<<<<< HEAD +<<<<<<< HEAD +fn maybe_side_effect() -> bool { +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD fn maybe_side_effect() -> bool { +======= +fn no_side_effects() -> bool { + true +} + +fn has_side_effects(a: &mut u32) -> bool { + *a = 1; +>>>>>>> 59bca098f (don't lint on `if let`) +======= +fn maybe_side_effect() -> bool { +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +fn maybe_side_effect() -> bool { +>>>>>>> 615b25c20 (Rebase attempt number 2) true } @@ -26,19 +101,95 @@ fn main() { // Lint if (true) {} // Do not remove the condition +<<<<<<< HEAD +<<<<<<< HEAD + if maybe_side_effect() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + if maybe_side_effect() {} +======= +fn main() { + // Lint + if (true) {} +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + if no_side_effects() {} + let mut x = 0; + if has_side_effects(&mut x) {} + assert_eq!(x, 1); +>>>>>>> 59bca098f (don't lint on `if let`) +======= + if maybe_side_effect() {} +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if maybe_side_effect() {} +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do not lint if (true) { } else { } +<<<<<<< HEAD +<<<<<<< HEAD + if { + return; + } {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + if { + return; + } {} +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + if { + return; + } {} +>>>>>>> 59bca098f (don't lint on `if let`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= if { return; } {} +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do not lint if `else if` is present if (true) { } else if (true) { } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // Do not lint `if let` or let chains + if let true = true {} + if let true = true && true {} + if true && let true = true {} + // Can lint nested `if let`s + if { + if let true = true && true { true } else { false } + } && true + {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // Ensure clippy does not bork this up, other cases should be added + if { + return; + } {} +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + // Do not lint if any `let` is present +======= // Do not lint `if let` or let chains +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) if let true = true {} if let true = true && true {} if true && let true = true {} @@ -47,11 +198,25 @@ fn main() { if let true = true && true { true } else { false } } && true {} +>>>>>>> 59bca098f (don't lint on `if let`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) external! { if (true) {} } with_span! { span if (true) {} } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) if true { // comment @@ -90,4 +255,15 @@ fn main() { if true {} let () = if maybe_side_effect() {}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_if.stderr b/tests/ui/needless_if.stderr index 14de400953bd..99df5e39158d 100644 --- a/tests/ui/needless_if.stderr +++ b/tests/ui/needless_if.stderr @@ -1,3 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: this `if` branch is empty --> $DIR/needless_if.rs:27:5 | @@ -7,14 +15,80 @@ LL | if (true) {} = note: `-D clippy::needless-if` implied by `-D warnings` error: this `if` branch is empty +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/needless_if.rs:29:5 +======= +<<<<<<< HEAD + --> $DIR/needless_if.rs:30:5 +<<<<<<< HEAD +======= + --> $DIR/needless_if.rs:29:5 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_if.rs:29:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) + | +LL | if maybe_side_effect() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `maybe_side_effect();` + +error: this `if` branch is empty +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_if.rs:34:5 + | +======= +<<<<<<< HEAD + --> $DIR/needless_if.rs:35:5 +======= +error: this if branch is empty + --> $DIR/needless_if.rs:19:5 +======= +error: this `if` branch is empty + --> $DIR/needless_if.rs:30:5 +>>>>>>> 59bca098f (don't lint on `if let`) + | +LL | if (true) {} + | ^^^^^^^^^^^^ help: you can remove it + | + = note: `-D clippy::needless-if` implied by `-D warnings` + +<<<<<<< HEAD +error: this if branch is empty + --> $DIR/needless_if.rs:29:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +error: this `if` branch is empty + --> $DIR/needless_if.rs:32:5 +======= +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) | LL | if maybe_side_effect() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `maybe_side_effect();` error: this `if` branch is empty +<<<<<<< HEAD + --> $DIR/needless_if.rs:34:5 + | +LL | if has_side_effects(&mut x) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `has_side_effects(&mut x);` + +error: this `if` branch is empty + --> $DIR/needless_if.rs:40:5 +>>>>>>> 59bca098f (don't lint on `if let`) +======= + --> $DIR/needless_if.rs:35:5 +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +======= --> $DIR/needless_if.rs:34:5 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) | +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_if.rs:34:5 + | +>>>>>>> 615b25c20 (Rebase attempt number 2) LL | / if { LL | | return; LL | | } {} @@ -22,6 +96,14 @@ LL | | } {} | help: you can remove it | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) LL ~ ({ LL + return; LL + }); @@ -62,4 +144,63 @@ LL | if true {} | ^^^^^^^^^^ help: you can remove it: `true;` error: aborting due to 7 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +LL ~ { +======= +LL ~ ({ +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +LL + return; +LL + }); + | + +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 2 previous errors +>>>>>>> 26f50395b (Add `needless_if` lint) +======= +error: aborting due to 4 previous errors +>>>>>>> 59bca098f (don't lint on `if let`) +======= +error: this `if` branch is empty + --> $DIR/needless_if.rs:47:5 + | +LL | / if { +LL | | if let true = true && true { true } else { false } +LL | | } && true +LL | | {} + | |______^ + | +help: you can remove it + | +LL ~ ({ +LL + if let true = true && true { true } else { false } +LL + } && true); + | + +error: this `if` branch is empty + --> $DIR/needless_if.rs:85:5 + | +LL | if { maybe_side_effect() } {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() });` + +error: this `if` branch is empty + --> $DIR/needless_if.rs:87:5 + | +LL | if { maybe_side_effect() } && true {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can remove it: `({ maybe_side_effect() } && true);` + +error: this `if` branch is empty + --> $DIR/needless_if.rs:91:5 + | +LL | if true {} + | ^^^^^^^^^^ help: you can remove it: `true;` + +error: aborting due to 7 previous errors +>>>>>>> 5e20a572e (Don't lint non-statement/faux empty `needless_if`s) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/needless_pub_self.fixed b/tests/ui/needless_pub_self.fixed index 672b4c318a8d..10872559907f 100644 --- a/tests/ui/needless_pub_self.fixed +++ b/tests/ui/needless_pub_self.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(unused)] #![warn(clippy::needless_pub_self)] diff --git a/tests/ui/needless_pub_self.rs b/tests/ui/needless_pub_self.rs index 5ac1edf8e990..41f73baf306d 100644 --- a/tests/ui/needless_pub_self.rs +++ b/tests/ui/needless_pub_self.rs @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(unused)] #![warn(clippy::needless_pub_self)] diff --git a/tests/ui/needless_range_loop.rs b/tests/ui/needless_range_loop.rs index a16ef5a5bca9..61e7f9f91d6c 100644 --- a/tests/ui/needless_range_loop.rs +++ b/tests/ui/needless_range_loop.rs @@ -1,9 +1,31 @@ #![warn(clippy::needless_range_loop)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::uninlined_format_args, clippy::unnecessary_literal_unwrap, clippy::useless_vec )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::uninlined_format_args, clippy::useless_vec)] +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) static STATIC: [usize; 4] = [0, 1, 8, 16]; const CONST: [usize; 4] = [0, 1, 8, 16]; diff --git a/tests/ui/needless_raw_string.fixed b/tests/ui/needless_raw_string.fixed index b36912efbb2d..b401a54bc6b6 100644 --- a/tests/ui/needless_raw_string.fixed +++ b/tests/ui/needless_raw_string.fixed @@ -1,6 +1,22 @@ //@run-rustfix #![allow(clippy::needless_raw_string_hashes, clippy::no_effect, unused)] +<<<<<<< HEAD +<<<<<<< HEAD #![warn(clippy::needless_raw_strings)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![warn(clippy::needless_raw_strings)] +======= +#![warn(clippy::needless_raw_string)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![warn(clippy::needless_raw_strings)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![warn(clippy::needless_raw_strings)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(c_str_literals)] fn main() { @@ -10,8 +26,26 @@ fn main() { b"aaa"; br#""aaa""#; br#"\s"#; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // currently disabled: /~https://github.com/rust-lang/rust/issues/113333 // cr#"aaa"#; // cr#""aaa""#; // cr#"\s"#; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + c"aaa"; + cr#""aaa""#; + cr#"\s"#; +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_raw_string.rs b/tests/ui/needless_raw_string.rs index 8f48e7dab2a6..5fb585d06c42 100644 --- a/tests/ui/needless_raw_string.rs +++ b/tests/ui/needless_raw_string.rs @@ -1,6 +1,22 @@ //@run-rustfix #![allow(clippy::needless_raw_string_hashes, clippy::no_effect, unused)] +<<<<<<< HEAD +<<<<<<< HEAD #![warn(clippy::needless_raw_strings)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![warn(clippy::needless_raw_strings)] +======= +#![warn(clippy::needless_raw_string)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![warn(clippy::needless_raw_strings)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![warn(clippy::needless_raw_strings)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(c_str_literals)] fn main() { @@ -10,8 +26,26 @@ fn main() { br#"aaa"#; br#""aaa""#; br#"\s"#; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // currently disabled: /~https://github.com/rust-lang/rust/issues/113333 // cr#"aaa"#; // cr#""aaa""#; // cr#"\s"#; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + cr#"aaa"#; + cr#""aaa""#; + cr#"\s"#; +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_raw_string.stderr b/tests/ui/needless_raw_string.stderr index cfb07b647d7c..588d16bc3dd6 100644 --- a/tests/ui/needless_raw_string.stderr +++ b/tests/ui/needless_raw_string.stderr @@ -4,7 +4,23 @@ error: unnecessary raw string literal LL | r#"aaa"#; | ^^^^^^^^ help: try: `"aaa"` | +<<<<<<< HEAD +<<<<<<< HEAD = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +======= +<<<<<<< HEAD +<<<<<<< HEAD + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +======= + = note: `-D clippy::needless-raw-string` implied by `-D warnings` +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: unnecessary raw string literal --> $DIR/needless_raw_string.rs:10:5 @@ -13,4 +29,20 @@ LL | br#"aaa"#; | ^^^^^^^^^ help: try: `b"aaa"` error: aborting due to 2 previous errors +<<<<<<< HEAD +======= +<<<<<<< HEAD +error: aborting due to 2 previous errors +======= +error: unnecessary raw string literal + --> $DIR/needless_raw_string.rs:13:5 + | +LL | cr#"aaa"#; + | ^^^^^^^^^ help: try: `c"aaa"` + +error: aborting due to 3 previous errors +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/needless_raw_string_hashes.fixed b/tests/ui/needless_raw_string_hashes.fixed index c8507c727151..caf265276595 100644 --- a/tests/ui/needless_raw_string_hashes.fixed +++ b/tests/ui/needless_raw_string_hashes.fixed @@ -4,6 +4,14 @@ #![feature(c_str_literals)] fn main() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) r#"aaa"#; r#"Hello "world"!"#; r####" "### "## "# "####; @@ -17,4 +25,34 @@ fn main() { // cr##"Hello "world"!"##; // cr######" "### "## "# "######; // cr######" "aa" "# "## "######; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + r"aaa"; +======= + r#"aaa"#; +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) + r#"Hello "world"!"#; + r####" "### "## "# "####; + r###" "aa" "# "## "###; + br#"aaa"#; + br#"Hello "world"!"#; + br####" "### "## "# "####; + br###" "aa" "# "## "###; + cr#"aaa"#; + cr#"Hello "world"!"#; + cr####" "### "## "# "####; + cr###" "aa" "# "## "###; +<<<<<<< HEAD +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= + // Issue #11068, do not lint + r##"a"#"a"##; + br##"a"#"a"##; + cr##"a"#"a"##; +>>>>>>> 9a581077d (Fix FP [`needless_raw_string_hashes`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_raw_string_hashes.rs b/tests/ui/needless_raw_string_hashes.rs index 912fbde1679d..0646801c16d4 100644 --- a/tests/ui/needless_raw_string_hashes.rs +++ b/tests/ui/needless_raw_string_hashes.rs @@ -12,9 +12,35 @@ fn main() { br##"Hello "world"!"##; br######" "### "## "# "######; br######" "aa" "# "## "######; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // currently disabled: /~https://github.com/rust-lang/rust/issues/113333 // cr#"aaa"#; // cr##"Hello "world"!"##; // cr######" "### "## "# "######; // cr######" "aa" "# "## "######; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + cr#"aaa"#; + cr##"Hello "world"!"##; + cr######" "### "## "# "######; + cr######" "aa" "# "## "######; +<<<<<<< HEAD +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= + // Issue #11068, do not lint + r##"a"#"a"##; + br##"a"#"a"##; + cr##"a"#"a"##; +>>>>>>> 9a581077d (Fix FP [`needless_raw_string_hashes`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/needless_raw_string_hashes.stderr b/tests/ui/needless_raw_string_hashes.stderr index 30e6783a38e8..b7a751ddf528 100644 --- a/tests/ui/needless_raw_string_hashes.stderr +++ b/tests/ui/needless_raw_string_hashes.stderr @@ -1,10 +1,48 @@ error: unnecessary hashes around raw string literal +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + --> $DIR/needless_raw_string_hashes.rs:7:5 + | +LL | r#"aaa"#; + | ^^^^^^^^ help: try: `r"aaa"` + | + = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` + +error: unnecessary hashes around raw string literal +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/needless_raw_string_hashes.rs:8:5 | LL | r##"Hello "world"!"##; | ^^^^^^^^^^^^^^^^^^^^^ help: try: `r#"Hello "world"!"#` +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | + = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` +======= +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= | = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + | + = note: `-D clippy::needless-raw-string-hashes` implied by `-D warnings` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: unnecessary hashes around raw string literal --> $DIR/needless_raw_string_hashes.rs:9:5 @@ -19,6 +57,24 @@ LL | r######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `r###" "aa" "# "## "###` error: unnecessary hashes around raw string literal +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + --> $DIR/needless_raw_string_hashes.rs:11:5 + | +LL | br#"aaa"#; + | ^^^^^^^^^ help: try: `br"aaa"` + +error: unnecessary hashes around raw string literal +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/needless_raw_string_hashes.rs:12:5 | LL | br##"Hello "world"!"##; @@ -37,4 +93,36 @@ LL | br######" "aa" "# "## "######; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `br###" "aa" "# "## "###` error: aborting due to 6 previous errors +<<<<<<< HEAD +======= +<<<<<<< HEAD +error: aborting due to 6 previous errors +======= +error: unnecessary hashes around raw string literal + --> $DIR/needless_raw_string_hashes.rs:16:5 + | +LL | cr##"Hello "world"!"##; + | ^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr#"Hello "world"!"#` + +error: unnecessary hashes around raw string literal + --> $DIR/needless_raw_string_hashes.rs:17:5 + | +LL | cr######" "### "## "# "######; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr####" "### "## "# "####` + +error: unnecessary hashes around raw string literal + --> $DIR/needless_raw_string_hashes.rs:18:5 + | +LL | cr######" "aa" "# "## "######; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `cr###" "aa" "# "## "###` + +<<<<<<< HEAD +error: aborting due to 12 previous errors +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +error: aborting due to 9 previous errors +>>>>>>> cb52d19ce (don't lint `needless_raw_string_hashes` when it's unnecessary) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/needless_return.stderr b/tests/ui/needless_return.stderr index 1d9d23d30083..01b8873164ed 100644 --- a/tests/ui/needless_return.stderr +++ b/tests/ui/needless_return.stderr @@ -475,6 +475,18 @@ error: unneeded `return` statement LL | return format!("Hello {}", "world!"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= + = help: remove `return` +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) help: remove `return` | LL - return format!("Hello {}", "world!"); @@ -483,6 +495,35 @@ LL + format!("Hello {}", "world!") error: unneeded `return` statement --> $DIR/needless_return.rs:251:9 +<<<<<<< HEAD +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) + | +LL - return format!("Hello {}", "world!"); +LL + format!("Hello {}", "world!") + | + +error: unneeded `return` statement + --> $DIR/needless_return.rs:253:9 +>>>>>>> 0567691cb (This commit resolves issue #10655) + | +LL - return format!("Hello {}", "world!"); +LL + format!("Hello {}", "world!") + | +<<<<<<< HEAD +======= +help: remove `return` + | +LL ~ true +LL | } else { +LL | return false; +LL ~ } + | +>>>>>>> 0567691cb (This commit resolves issue #10655) + +error: unneeded `return` statement + --> $DIR/needless_return.rs:253:9 +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return true; | ^^^^^^^^^^^ @@ -508,7 +549,23 @@ LL ~ } | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/needless_return.rs:260:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:260:13 +======= + --> $DIR/needless_return.rs:259:13 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:260:13 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_return.rs:260:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return 10; | ^^^^^^^^^ @@ -523,7 +580,23 @@ LL ~ } | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:263:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:263:13 +======= + --> $DIR/needless_return.rs:262:13 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:263:13 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/needless_return.rs:263:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return 100; | ^^^^^^^^^^ @@ -536,11 +609,39 @@ LL ~ } | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/needless_return.rs:271:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:271:9 +======= + --> $DIR/needless_return.rs:270:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:271:9 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_return.rs:271:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return 0; | ^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= + = help: remove `return` +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) help: remove `return` | LL ~ 0 @@ -549,6 +650,36 @@ LL ~ } error: unneeded `return` statement --> $DIR/needless_return.rs:278:13 +<<<<<<< HEAD +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) + | +LL ~ 0 +LL ~ } + | + +error: unneeded `return` statement + --> $DIR/needless_return.rs:280:13 +>>>>>>> 0567691cb (This commit resolves issue #10655) + | +LL ~ 0 +LL ~ } + | +<<<<<<< HEAD +======= +help: remove `return` + | +LL ~ *(x as *const isize) +LL | } else { +LL | return !*(x as *const isize); +LL ~ } +LL ~ } + | +>>>>>>> 0567691cb (This commit resolves issue #10655) + +error: unneeded `return` statement + --> $DIR/needless_return.rs:280:13 +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return *(x as *const isize); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -576,7 +707,23 @@ LL ~ } | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/needless_return.rs:287:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:287:20 +======= + --> $DIR/needless_return.rs:286:20 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:287:20 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_return.rs:287:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = 42; | ____________________^ @@ -593,11 +740,39 @@ LL + let _ = 42; | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:294:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:294:20 +======= + --> $DIR/needless_return.rs:293:20 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:294:20 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/needless_return.rs:294:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = 42; return; | ^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: remove `return` +======= + = help: remove `return` +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) help: remove `return` | LL - let _ = 42; return; @@ -606,6 +781,33 @@ LL + let _ = 42; error: unneeded `return` statement --> $DIR/needless_return.rs:306:9 +<<<<<<< HEAD +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) + | +LL - let _ = 42; return; +LL + let _ = 42; + | + +error: unneeded `return` statement + --> $DIR/needless_return.rs:308:9 +>>>>>>> 0567691cb (This commit resolves issue #10655) + | +LL - let _ = 42; return; +LL + let _ = 42; + | +<<<<<<< HEAD +======= +help: remove `return` + | +LL - return Ok(format!("ok!")); +LL + Ok(format!("ok!")) + | +>>>>>>> 0567691cb (This commit resolves issue #10655) + +error: unneeded `return` statement + --> $DIR/needless_return.rs:308:9 +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return Ok(format!("ok!")); | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -629,7 +831,23 @@ LL + Err(format!("err!")) | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:314:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/needless_return.rs:314:9 +======= + --> $DIR/needless_return.rs:313:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:314:9 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/needless_return.rs:314:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return if true { 1 } else { 2 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -641,7 +859,23 @@ LL + if true { 1 } else { 2 } | error: unneeded `return` statement +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:318:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/needless_return.rs:318:9 +======= + --> $DIR/needless_return.rs:317:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +======= + --> $DIR/needless_return.rs:318:9 +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/needless_return.rs:318:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | return if b1 { 0 } else { 1 } | if b2 { 2 } else { 3 } | if b3 { 4 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/never_loop.stderr b/tests/ui/never_loop.stderr index 0446c09cd5bc..1bf9768e1e7c 100644 --- a/tests/ui/never_loop.stderr +++ b/tests/ui/never_loop.stderr @@ -127,7 +127,23 @@ LL | | } | |_____^ error: sub-expression diverges +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/never_loop.rs:249:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/never_loop.rs:249:17 +======= + --> $DIR/never_loop.rs:247:17 +>>>>>>> 5825b9e3e (actually fix it) +======= + --> $DIR/never_loop.rs:249:17 +>>>>>>> 6a1084c26 (Check if `if` conditions always evaluate to true in `never_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/never_loop.rs:249:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | break 'a; | ^^^^^^^^ @@ -147,6 +163,16 @@ help: if you need the first element of the iterator, try writing LL | if let Some(_) = (0..20).next() { | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 6a1084c26 (Check if `if` conditions always evaluate to true in `never_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: this loop never actually loops --> $DIR/never_loop.rs:324:5 | @@ -160,4 +186,16 @@ LL | | } | |_____^ error: aborting due to 14 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 13 previous errors +>>>>>>> 5825b9e3e (actually fix it) +======= +>>>>>>> 6a1084c26 (Check if `if` conditions always evaluate to true in `never_loop`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/non_minimal_cfg.fixed b/tests/ui/non_minimal_cfg.fixed index 430caafb33e1..c984aacb1233 100644 --- a/tests/ui/non_minimal_cfg.fixed +++ b/tests/ui/non_minimal_cfg.fixed @@ -11,7 +11,28 @@ fn wasi() {} #[cfg(all(unix, not(windows)))] fn the_end() {} +<<<<<<< HEAD +<<<<<<< HEAD #[cfg(any())] fn any() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[cfg(any())] +fn any() {} + +======= +>>>>>>> fcf19481a (Add UI test for UNIQUE_CFG_CONDITION) +======= +#[cfg(any())] +fn any() {} + +>>>>>>> dbc76a766 (Add check for empty cfg `all` condition) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[cfg(any())] +fn any() {} + +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/non_minimal_cfg.rs b/tests/ui/non_minimal_cfg.rs index a38ce1c21d6e..e69257749b47 100644 --- a/tests/ui/non_minimal_cfg.rs +++ b/tests/ui/non_minimal_cfg.rs @@ -11,7 +11,28 @@ fn wasi() {} #[cfg(all(any(unix), all(not(windows))))] fn the_end() {} +<<<<<<< HEAD +<<<<<<< HEAD #[cfg(any())] fn any() {} +======= +<<<<<<< HEAD +<<<<<<< HEAD +#[cfg(any())] +fn any() {} + +======= +>>>>>>> fcf19481a (Add UI test for UNIQUE_CFG_CONDITION) +======= +#[cfg(any())] +fn any() {} + +>>>>>>> dbc76a766 (Add check for empty cfg `all` condition) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#[cfg(any())] +fn any() {} + +>>>>>>> 615b25c20 (Rebase attempt number 2) fn main() {} diff --git a/tests/ui/nonminimal_bool.stderr b/tests/ui/nonminimal_bool.stderr index e2e4d6477c9f..a742e6a4883a 100644 --- a/tests/ui/nonminimal_bool.stderr +++ b/tests/ui/nonminimal_bool.stderr @@ -13,13 +13,48 @@ LL | let _ = !false; | ^^^^^^ help: try: `true` error: this boolean expression can be simplified +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/nonminimal_bool.rs:14:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/nonminimal_bool.rs:14:13 +======= + --> $DIR/nonminimal_bool.rs:13:13 +>>>>>>> e4927f98f (change booleans file and update tests) +======= + --> $DIR/nonminimal_bool.rs:14:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/nonminimal_bool.rs:14:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = !!a; | ^^^ help: try: `a` error: this boolean expression can be simplified +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/nonminimal_bool.rs:15:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d3534a652 (fix issues 10836) + --> $DIR/nonminimal_bool.rs:15:13 +======= + --> $DIR/nonminimal_bool.rs:14:13 +>>>>>>> e4927f98f (change booleans file and update tests) +======= + --> $DIR/nonminimal_bool.rs:15:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/nonminimal_bool.rs:15:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = false || a; | ^^^^^^^^^^ help: try: `a` diff --git a/tests/ui/option_if_let_else.fixed b/tests/ui/option_if_let_else.fixed index 8e59e4375d2e..0d1f92e0a282 100644 --- a/tests/ui/option_if_let_else.fixed +++ b/tests/ui/option_if_let_else.fixed @@ -210,7 +210,23 @@ fn issue9742() -> Option<&'static str> { } mod issue10729 { +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::unit_arg, dead_code)] +======= +<<<<<<< HEAD +<<<<<<< HEAD + #![allow(clippy::unit_arg, dead_code)] +======= + #![allow(clippy::unit_arg)] +>>>>>>> 733a9ea6b ([`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>`) +======= + #![allow(clippy::unit_arg, dead_code)] +>>>>>>> cee4c4169 (allow dead code in the test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #![allow(clippy::unit_arg, dead_code)] +>>>>>>> 615b25c20 (Rebase attempt number 2) pub fn reproduce(initial: &Option) { // 👇 needs `.as_ref()` because initial is an `&Option<_>` diff --git a/tests/ui/option_if_let_else.rs b/tests/ui/option_if_let_else.rs index e72edf2a8e31..2321d88fef7b 100644 --- a/tests/ui/option_if_let_else.rs +++ b/tests/ui/option_if_let_else.rs @@ -251,7 +251,23 @@ fn issue9742() -> Option<&'static str> { } mod issue10729 { +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::unit_arg, dead_code)] +======= +<<<<<<< HEAD +<<<<<<< HEAD + #![allow(clippy::unit_arg, dead_code)] +======= + #![allow(clippy::unit_arg)] +>>>>>>> 733a9ea6b ([`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>`) +======= + #![allow(clippy::unit_arg, dead_code)] +>>>>>>> cee4c4169 (allow dead code in the test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #![allow(clippy::unit_arg, dead_code)] +>>>>>>> 615b25c20 (Rebase attempt number 2) pub fn reproduce(initial: &Option) { // 👇 needs `.as_ref()` because initial is an `&Option<_>` diff --git a/tests/ui/option_if_let_else.stderr b/tests/ui/option_if_let_else.stderr index aa2da2174003..3f720eac823c 100644 --- a/tests/ui/option_if_let_else.stderr +++ b/tests/ui/option_if_let_else.stderr @@ -271,8 +271,28 @@ error: use Option::map_or instead of an if let/else LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` +<<<<<<< HEAD +<<<<<<< HEAD error: use Option::map_or instead of an if let/else --> $DIR/option_if_let_else.rs:258:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: use Option::map_or instead of an if let/else + --> $DIR/option_if_let_else.rs:258:9 +======= +error: use Option::map_or instead of an if let/else +<<<<<<< HEAD + --> $DIR/option_if_let_else.rs:260:9 +>>>>>>> 733a9ea6b ([`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>`) +======= + --> $DIR/option_if_let_else.rs:258:9 +>>>>>>> cee4c4169 (allow dead code in the test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: use Option::map_or instead of an if let/else + --> $DIR/option_if_let_else.rs:258:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match initial { LL | | Some(value) => do_something(value), @@ -281,7 +301,23 @@ LL | | } | |_________^ help: try: `initial.as_ref().map_or({}, |value| do_something(value))` error: use Option::map_or instead of an if let/else +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/option_if_let_else.rs:265:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/option_if_let_else.rs:265:9 +======= + --> $DIR/option_if_let_else.rs:267:9 +>>>>>>> 733a9ea6b ([`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>`) +======= + --> $DIR/option_if_let_else.rs:265:9 +>>>>>>> cee4c4169 (allow dead code in the test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/option_if_let_else.rs:265:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match initial { LL | | Some(value) => do_something2(value), @@ -290,4 +326,16 @@ LL | | } | |_________^ help: try: `initial.as_mut().map_or({}, |value| do_something2(value))` error: aborting due to 23 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 21 previous errors +>>>>>>> d80ca09f5 (Fix: Some suggestions generated by the option_if_let_else lint did not compile) +======= +>>>>>>> 733a9ea6b ([`option_if_let_else`]: suggest `.as_ref()` if `&Option<_>`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/or_fun_call.fixed b/tests/ui/or_fun_call.fixed index 6deff0f3240a..d48c3ee7d035 100644 --- a/tests/ui/or_fun_call.fixed +++ b/tests/ui/or_fun_call.fixed @@ -5,7 +5,22 @@ clippy::borrow_as_ptr, clippy::uninlined_format_args, clippy::unnecessary_wraps, +<<<<<<< HEAD +<<<<<<< HEAD clippy::unnecessary_literal_unwrap, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::unnecessary_literal_unwrap, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::unnecessary_literal_unwrap, +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::unnecessary_literal_unwrap, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::useless_vec )] diff --git a/tests/ui/or_fun_call.rs b/tests/ui/or_fun_call.rs index b05b33e6ee2b..c8d29113c019 100644 --- a/tests/ui/or_fun_call.rs +++ b/tests/ui/or_fun_call.rs @@ -5,7 +5,22 @@ clippy::borrow_as_ptr, clippy::uninlined_format_args, clippy::unnecessary_wraps, +<<<<<<< HEAD +<<<<<<< HEAD clippy::unnecessary_literal_unwrap, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::unnecessary_literal_unwrap, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::unnecessary_literal_unwrap, +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::unnecessary_literal_unwrap, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::useless_vec )] diff --git a/tests/ui/or_fun_call.stderr b/tests/ui/or_fun_call.stderr index 7342b0c2914b..ccaee31bc6bf 100644 --- a/tests/ui/or_fun_call.stderr +++ b/tests/ui/or_fun_call.stderr @@ -1,5 +1,25 @@ error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/or_fun_call.rs:53:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:54:22 +======= + --> $DIR/or_fun_call.rs:53:22 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:54:22 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:53:22 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:53:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_constructor.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(make)` @@ -7,163 +27,703 @@ LL | with_constructor.unwrap_or(make()); = note: `-D clippy::or-fun-call` implied by `-D warnings` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:56:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:57:14 +======= + --> $DIR/or_fun_call.rs:56:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:57:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:56:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:56:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_new.unwrap_or(Vec::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/or_fun_call.rs:59:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:60:21 +======= + --> $DIR/or_fun_call.rs:59:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:60:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:59:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:59:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_const_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:62:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:63:14 +======= + --> $DIR/or_fun_call.rs:62:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:63:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:62:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:62:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_err.unwrap_or(make()); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| make())` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:65:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:66:19 +======= + --> $DIR/or_fun_call.rs:65:19 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:66:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:65:19 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:65:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_err_args.unwrap_or(Vec::with_capacity(12)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|_| Vec::with_capacity(12))` error: use of `unwrap_or` followed by a call to `default` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:68:24 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:69:24 +======= + --> $DIR/or_fun_call.rs:68:24 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:69:24 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:68:24 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:68:24 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_default_trait.unwrap_or(Default::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a call to `default` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:71:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:72:23 +======= + --> $DIR/or_fun_call.rs:71:23 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:72:23 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:71:23 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:71:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_default_type.unwrap_or(u64::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:74:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:75:18 +======= --> $DIR/or_fun_call.rs:74:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:75:18 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:74:18 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:74:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | self_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(::default)` error: use of `unwrap_or` followed by a call to `default` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:77:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:78:18 +======= --> $DIR/or_fun_call.rs:77:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:78:18 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:77:18 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:77:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | real_default.unwrap_or(::default()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:80:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:81:14 +======= --> $DIR/or_fun_call.rs:80:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:81:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:80:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:80:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | with_vec.unwrap_or(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:83:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:84:21 +======= + --> $DIR/or_fun_call.rs:83:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:84:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:83:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:83:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | without_default.unwrap_or(Foo::new()); | ^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(Foo::new)` error: use of `or_insert` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/or_fun_call.rs:86:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:87:19 +======= + --> $DIR/or_fun_call.rs:86:19 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:87:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:86:19 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:86:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | map.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:89:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:90:23 +======= + --> $DIR/or_fun_call.rs:89:23 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:90:23 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:89:23 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:89:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | map_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:92:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:93:21 +======= + --> $DIR/or_fun_call.rs:92:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:93:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:92:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:92:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | btree.entry(42).or_insert(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `or_insert` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:95:25 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:96:25 +======= --> $DIR/or_fun_call.rs:95:25 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:96:25 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:95:25 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:95:25 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | btree_vec.entry(42).or_insert(vec![]); | ^^^^^^^^^^^^^^^^^ help: try: `or_default()` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:98:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:99:21 +======= --> $DIR/or_fun_call.rs:98:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:99:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:98:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:98:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = stringy.unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:106:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:107:21 +======= --> $DIR/or_fun_call.rs:106:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:107:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:106:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:106:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:108:21 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:109:21 +======= + --> $DIR/or_fun_call.rs:108:21 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:109:21 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:108:21 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:108:21 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(1).unwrap_or(map[&1]); | ^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| map[&1])` error: use of `or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/or_fun_call.rs:132:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:133:35 +======= + --> $DIR/or_fun_call.rs:132:35 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:133:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:132:35 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:132:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some("a".to_string()).or(Some("b".to_string())); | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `or_else(|| Some("b".to_string()))` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:171:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:172:14 +======= + --> $DIR/or_fun_call.rs:171:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:172:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:171:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:171:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | None.unwrap_or(ptr_to_ref(s)); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| ptr_to_ref(s))` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/or_fun_call.rs:177:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:178:14 +======= + --> $DIR/or_fun_call.rs:177:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:178:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:177:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:177:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | None.unwrap_or(unsafe { ptr_to_ref(s) }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `unwrap_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:179:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:180:14 +======= + --> $DIR/or_fun_call.rs:179:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:180:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:179:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:179:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | None.unwrap_or( unsafe { ptr_to_ref(s) } ); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_else(|| unsafe { ptr_to_ref(s) })` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:193:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:194:14 +======= + --> $DIR/or_fun_call.rs:193:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:194:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:193:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:193:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:206:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:207:14 +======= + --> $DIR/or_fun_call.rs:206:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:207:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:206:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:206:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:218:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:219:14 +======= + --> $DIR/or_fun_call.rs:218:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:219:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= --> $DIR/or_fun_call.rs:218:14 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:218:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `unwrap_or` followed by a call to `new` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:229:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:230:10 +======= --> $DIR/or_fun_call.rs:229:10 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:230:10 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:229:10 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/or_fun_call.rs:229:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | .unwrap_or(String::new()); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` error: use of `map_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:254:25 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:255:25 +======= + --> $DIR/or_fun_call.rs:254:25 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:255:25 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:254:25 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:254:25 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(4).map_or(g(), |v| v); | ^^^^^^^^^^^^^^^^^^ help: try: `map_or_else(g, |v| v)` error: use of `map_or` followed by a function call +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:255:25 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/or_fun_call.rs:256:25 +======= + --> $DIR/or_fun_call.rs:255:25 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/or_fun_call.rs:256:25 +>>>>>>> bfd5abad4 (Fix all the other tests) +======= + --> $DIR/or_fun_call.rs:255:25 +>>>>>>> 2811effe3 (Add `imports_granularity = "Module"` to rustfmt.toml) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/or_fun_call.rs:255:25 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(4).map_or(g(), f); | ^^^^^^^^^^^^^^ help: try: `map_or_else(g, f)` diff --git a/tests/ui/partialeq_to_none.fixed b/tests/ui/partialeq_to_none.fixed index 95e184b1de6c..8fd450d91afe 100644 --- a/tests/ui/partialeq_to_none.fixed +++ b/tests/ui/partialeq_to_none.fixed @@ -1,6 +1,22 @@ //@run-rustfix #![warn(clippy::partialeq_to_none)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::eq_op, clippy::needless_if)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::eq_op, clippy::needless_if)] +======= +#![allow(clippy::eq_op)] +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= +#![allow(clippy::eq_op, clippy::needless_if)] +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::eq_op, clippy::needless_if)] +>>>>>>> 615b25c20 (Rebase attempt number 2) struct Foobar; diff --git a/tests/ui/partialeq_to_none.rs b/tests/ui/partialeq_to_none.rs index 4fa50dcc11b6..bb91b336c0af 100644 --- a/tests/ui/partialeq_to_none.rs +++ b/tests/ui/partialeq_to_none.rs @@ -1,6 +1,22 @@ //@run-rustfix #![warn(clippy::partialeq_to_none)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::eq_op, clippy::needless_if)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::eq_op, clippy::needless_if)] +======= +#![allow(clippy::eq_op)] +>>>>>>> 58132cb3b (Improve `SpanlessEq`) +======= +#![allow(clippy::eq_op, clippy::needless_if)] +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::eq_op, clippy::needless_if)] +>>>>>>> 615b25c20 (Rebase attempt number 2) struct Foobar; diff --git a/tests/ui/ptr_cast_constness.fixed b/tests/ui/ptr_cast_constness.fixed index 1ef1809d1530..d5fb7e6966c2 100644 --- a/tests/ui/ptr_cast_constness.fixed +++ b/tests/ui/ptr_cast_constness.fixed @@ -1,25 +1,95 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@aux-build:proc_macros.rs:proc-macro #![warn(clippy::ptr_cast_constness)] #![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +//@aux-build:proc_macros.rs + +#![warn(clippy::ptr_cast_constness)] +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 8c191add8 (the implementation!!) +======= +#![allow(clippy::transmute_ptr_to_ref, unused)] +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +======= +#![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)] +>>>>>>> cd1d7a3c6 (weird) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; use proc_macros::{external, inline_macros}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe fn ptr_to_ref(p: *const T, om: *mut U) { let _: &mut T = std::mem::transmute(p.cast_mut()); let _ = &mut *p.cast_mut(); let _: &T = &*(om as *const T); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 8c191add8 (the implementation!!) +======= +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[inline_macros] fn main() { let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; +<<<<<<< HEAD +<<<<<<< HEAD + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +======= + let _ = ptr as *const i32; + let _ = mut_ptr as *mut i32; +>>>>>>> 8c191add8 (the implementation!!) +======= + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let _ = ptr as *const u32; let _ = mut_ptr as *mut u32; +>>>>>>> 615b25c20 (Rebase attempt number 2) // Make sure the lint can handle the difference in their operator precedences. unsafe { @@ -36,6 +106,14 @@ fn main() { let _ = ptr_of_array as *const dyn std::fmt::Debug; // Make sure the lint is triggered inside a macro +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = inline!($ptr as *const u32); // Do not lint inside macros from external crates @@ -44,16 +122,72 @@ fn main() { #[clippy::msrv = "1.64"] fn _msrv_1_64() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let _ = inline!($ptr as *const i32); +======= + let _ = inline!($ptr as *const u32); +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) + + // Do not lint inside macros from external crates + let _ = external!($ptr as *const u32); +} + +#[clippy::msrv = "1.64"] +<<<<<<< HEAD +fn _msrv_1_37() { +>>>>>>> 8c191add8 (the implementation!!) +======= +fn _msrv_1_64() { +>>>>>>> 4ff1cd365 (add description and rename msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; // `pointer::cast_const` and `pointer::cast_mut` were stabilized in 1.65. Do not lint this +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = ptr as *mut u32; let _ = mut_ptr as *const u32; } #[clippy::msrv = "1.65"] fn _msrv_1_65() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let _ = ptr.cast_mut(); + let _ = mut_ptr.cast_const(); +======= + let _ = ptr as *mut i32; + let _ = mut_ptr as *const i32; +>>>>>>> c5a914b18 (check msrv) +} + +#[clippy::msrv = "1.65"] +<<<<<<< HEAD +fn _msrv_1_38() { +>>>>>>> 8c191add8 (the implementation!!) +======= +fn _msrv_1_65() { +>>>>>>> 4ff1cd365 (add description and rename msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; diff --git a/tests/ui/ptr_cast_constness.rs b/tests/ui/ptr_cast_constness.rs index 2c15cd429daf..78fecb11ff36 100644 --- a/tests/ui/ptr_cast_constness.rs +++ b/tests/ui/ptr_cast_constness.rs @@ -1,34 +1,132 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@aux-build:proc_macros.rs:proc-macro #![warn(clippy::ptr_cast_constness)] #![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +//@aux-build:proc_macros.rs + +#![warn(clippy::ptr_cast_constness)] +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 8c191add8 (the implementation!!) +======= +#![allow(clippy::transmute_ptr_to_ref, unused)] +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +======= +#![allow(clippy::transmute_ptr_to_ref, clippy::unnecessary_cast, unused)] +>>>>>>> cd1d7a3c6 (weird) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; use proc_macros::{external, inline_macros}; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe fn ptr_to_ref(p: *const T, om: *mut U) { let _: &mut T = std::mem::transmute(p as *mut T); let _ = &mut *(p as *mut T); let _: &T = &*(om as *const T); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 8c191add8 (the implementation!!) +======= +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[inline_macros] fn main() { let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; +<<<<<<< HEAD +<<<<<<< HEAD + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +======= + let _ = ptr as *const i32; + let _ = mut_ptr as *mut i32; +>>>>>>> 8c191add8 (the implementation!!) +======= + let _ = ptr as *const u32; + let _ = mut_ptr as *mut u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let _ = ptr as *const u32; let _ = mut_ptr as *mut u32; +>>>>>>> 615b25c20 (Rebase attempt number 2) // Make sure the lint can handle the difference in their operator precedences. unsafe { let ptr_ptr: *const *const u32 = &ptr; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = *ptr_ptr as *mut u32; } let _ = ptr as *mut u32; let _ = mut_ptr as *const u32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let _ = *ptr_ptr as *mut i32; + } + + let _ = ptr as *mut i32; + let _ = mut_ptr as *const i32; +>>>>>>> 8c191add8 (the implementation!!) +======= + let _ = *ptr_ptr as *mut u32; + } + + let _ = ptr as *mut u32; + let _ = mut_ptr as *const u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Lint this, since pointer::cast_mut and pointer::cast_const have ?Sized let ptr_of_array: *const [u32; 4] = &[1, 2, 3, 4]; @@ -36,6 +134,14 @@ fn main() { let _ = ptr_of_array as *const dyn std::fmt::Debug; // Make sure the lint is triggered inside a macro +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = inline!($ptr as *const u32); // Do not lint inside macros from external crates @@ -44,12 +150,62 @@ fn main() { #[clippy::msrv = "1.64"] fn _msrv_1_64() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let _ = inline!($ptr as *const i32); +======= + let _ = inline!($ptr as *const u32); +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) + + // Do not lint inside macros from external crates + let _ = external!($ptr as *const u32); +} + +#[clippy::msrv = "1.64"] +<<<<<<< HEAD +fn _msrv_1_37() { +>>>>>>> 8c191add8 (the implementation!!) +======= +fn _msrv_1_64() { +>>>>>>> 4ff1cd365 (add description and rename msrv tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; // `pointer::cast_const` and `pointer::cast_mut` were stabilized in 1.65. Do not lint this +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + let _ = ptr as *mut u32; + let _ = mut_ptr as *const u32; +} + +#[clippy::msrv = "1.65"] +fn _msrv_1_65() { + let ptr: *const u32 = &42_u32; + let mut_ptr: *mut u32 = &mut 42_u32; + + let _ = ptr as *mut u32; + let _ = mut_ptr as *const u32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + let _ = ptr as *mut i32; + let _ = mut_ptr as *const i32; +======= let _ = ptr as *mut u32; let _ = mut_ptr as *const u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) } #[clippy::msrv = "1.65"] @@ -57,6 +213,15 @@ fn _msrv_1_65() { let ptr: *const u32 = &42_u32; let mut_ptr: *mut u32 = &mut 42_u32; +<<<<<<< HEAD + let _ = ptr as *mut i32; + let _ = mut_ptr as *const i32; +>>>>>>> 8c191add8 (the implementation!!) +======= let _ = ptr as *mut u32; let _ = mut_ptr as *const u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/ptr_cast_constness.stderr b/tests/ui/ptr_cast_constness.stderr index 0c3ff863685b..f5908f687676 100644 --- a/tests/ui/ptr_cast_constness.stderr +++ b/tests/ui/ptr_cast_constness.stderr @@ -1,3 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: `as` casting between raw pointers while changing only its constness --> $DIR/ptr_cast_constness.rs:11:41 | @@ -40,6 +48,64 @@ error: `as` casting between raw pointers while changing only its constness --> $DIR/ptr_cast_constness.rs:61:13 | LL | let _ = mut_ptr as *const u32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: `as` casting between raw pointers while changing its constness + --> $DIR/ptr_cast_constness.rs:20:17 +======= +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:11:41 +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) + | +LL | let _: &mut T = std::mem::transmute(p as *mut T); + | ^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` + | + = note: `-D clippy::ptr-cast-constness` implied by `-D warnings` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:12:19 + | +LL | let _ = &mut *(p as *mut T); + | ^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `p.cast_mut()` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:27:17 + | +LL | let _ = *ptr_ptr as *mut u32; + | ^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `(*ptr_ptr).cast_mut()` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:30:13 + | +LL | let _ = ptr as *mut u32; + | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:31:13 + | +LL | let _ = mut_ptr as *const u32; + | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:60:13 + | +LL | let _ = ptr as *mut u32; + | ^^^^^^^^^^^^^^^ help: try `pointer::cast_mut`, a safer alternative: `ptr.cast_mut()` + +error: `as` casting between raw pointers while changing only its constness + --> $DIR/ptr_cast_constness.rs:61:13 + | +<<<<<<< HEAD +LL | let _ = mut_ptr as *const i32; +>>>>>>> 8c191add8 (the implementation!!) +======= +LL | let _ = mut_ptr as *const u32; +>>>>>>> ad7c44b3e (only lint when `cast_from` and `cast_to`'s ty are the same) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | ^^^^^^^^^^^^^^^^^^^^^ help: try `pointer::cast_const`, a safer alternative: `mut_ptr.cast_const()` error: aborting due to 7 previous errors diff --git a/tests/ui/pub_with_shorthand.fixed b/tests/ui/pub_with_shorthand.fixed index a774faa0a673..0c7de7bdac50 100644 --- a/tests/ui/pub_with_shorthand.fixed +++ b/tests/ui/pub_with_shorthand.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(clippy::needless_pub_self, unused)] #![warn(clippy::pub_with_shorthand)] diff --git a/tests/ui/pub_with_shorthand.rs b/tests/ui/pub_with_shorthand.rs index 4a4bbc18728e..5d5629099c59 100644 --- a/tests/ui/pub_with_shorthand.rs +++ b/tests/ui/pub_with_shorthand.rs @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(clippy::needless_pub_self, unused)] #![warn(clippy::pub_with_shorthand)] diff --git a/tests/ui/pub_without_shorthand.fixed b/tests/ui/pub_without_shorthand.fixed index fdb49ac4d906..b5bc0ab988e0 100644 --- a/tests/ui/pub_without_shorthand.fixed +++ b/tests/ui/pub_without_shorthand.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(clippy::needless_pub_self, unused)] #![warn(clippy::pub_without_shorthand)] diff --git a/tests/ui/pub_without_shorthand.rs b/tests/ui/pub_without_shorthand.rs index 1f2ef7ece391..e0ba95bdc74c 100644 --- a/tests/ui/pub_without_shorthand.rs +++ b/tests/ui/pub_without_shorthand.rs @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 8296a338d (new lints for visibility) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 46aa8abf0 (Change category and update to `ui_test`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![feature(custom_inner_attributes)] #![allow(clippy::needless_pub_self, unused)] #![warn(clippy::pub_without_shorthand)] diff --git a/tests/ui/question_mark.fixed b/tests/ui/question_mark.fixed index 2d8920ccc42f..321c377d0568 100644 --- a/tests/ui/question_mark.fixed +++ b/tests/ui/question_mark.fixed @@ -239,6 +239,16 @@ fn issue8628(a: Option) -> Option { b.or(Some(128)) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn issue6828_nested_body() -> Option { try { fn f2(a: Option) -> Option { @@ -249,6 +259,17 @@ fn issue6828_nested_body() -> Option { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 716305d4b ([`question_mark`]: don't lint inside of `try` block) +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // should not lint, `?` operator not available in const context const fn issue9175(option: Option<()>) -> Option<()> { if option.is_none() { diff --git a/tests/ui/question_mark.rs b/tests/ui/question_mark.rs index 69451c17ee7a..3a66f86a5b84 100644 --- a/tests/ui/question_mark.rs +++ b/tests/ui/question_mark.rs @@ -275,6 +275,16 @@ fn issue8628(a: Option) -> Option { b.or(Some(128)) } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn issue6828_nested_body() -> Option { try { fn f2(a: Option) -> Option { @@ -289,6 +299,17 @@ fn issue6828_nested_body() -> Option { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 716305d4b ([`question_mark`]: don't lint inside of `try` block) +======= +>>>>>>> 70610c001 (lint in nested bodies if `try` is in outer body) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // should not lint, `?` operator not available in const context const fn issue9175(option: Option<()>) -> Option<()> { if option.is_none() { diff --git a/tests/ui/redundant_clone.fixed b/tests/ui/redundant_clone.fixed index 5037c08ebd5f..8436f2cff9b0 100644 --- a/tests/ui/redundant_clone.fixed +++ b/tests/ui/redundant_clone.fixed @@ -2,12 +2,34 @@ // rustfix-only-machine-applicable #![feature(lint_reasons)] #![warn(clippy::redundant_clone)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args, clippy::unnecessary_literal_unwrap )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)] +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::ffi::OsString; use std::path::Path; diff --git a/tests/ui/redundant_clone.rs b/tests/ui/redundant_clone.rs index 501898bf113c..0cd04cb2b982 100644 --- a/tests/ui/redundant_clone.rs +++ b/tests/ui/redundant_clone.rs @@ -2,12 +2,34 @@ // rustfix-only-machine-applicable #![feature(lint_reasons)] #![warn(clippy::redundant_clone)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args, clippy::unnecessary_literal_unwrap )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::drop_non_drop, clippy::implicit_clone, clippy::uninlined_format_args)] +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::ffi::OsString; use std::path::Path; diff --git a/tests/ui/redundant_clone.stderr b/tests/ui/redundant_clone.stderr index 8660c0e1f6a0..bf6cf56da25a 100644 --- a/tests/ui/redundant_clone.stderr +++ b/tests/ui/redundant_clone.stderr @@ -1,125 +1,455 @@ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:16:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:16:42 +======= + --> $DIR/redundant_clone.rs:11:42 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:16:42 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:16:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:16:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:16:14 +======= + --> $DIR/redundant_clone.rs:11:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:16:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:16:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = ["lorem", "ipsum"].join(" ").to_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: `-D clippy::redundant-clone` implied by `-D warnings` error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:19:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:19:15 +======= + --> $DIR/redundant_clone.rs:14:15 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:19:15 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:19:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:19:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:19:14 +======= + --> $DIR/redundant_clone.rs:14:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:19:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:19:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.clone(); | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:22:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:22:15 +======= + --> $DIR/redundant_clone.rs:17:15 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:22:15 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:22:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.to_string(); | ^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:22:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:22:14 +======= + --> $DIR/redundant_clone.rs:17:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:22:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:22:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.to_string(); | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:25:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:25:15 +======= + --> $DIR/redundant_clone.rs:20:15 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:25:15 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:25:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:25:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:25:14 +======= + --> $DIR/redundant_clone.rs:20:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= --> $DIR/redundant_clone.rs:25:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:25:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = s.to_owned(); | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:27:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:27:42 +======= + --> $DIR/redundant_clone.rs:22:42 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= --> $DIR/redundant_clone.rs:27:42 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:27:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:27:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:27:14 +======= + --> $DIR/redundant_clone.rs:22:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:27:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:27:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = Path::new("/a/b/").join("c").to_owned(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:29:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:29:42 +======= + --> $DIR/redundant_clone.rs:24:42 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:29:42 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:29:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:29:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:29:14 +======= + --> $DIR/redundant_clone.rs:24:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:29:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:29:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = Path::new("/a/b/").join("c").to_path_buf(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:31:29 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:31:29 +======= + --> $DIR/redundant_clone.rs:26:29 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:31:29 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:31:29 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:31:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:31:14 +======= + --> $DIR/redundant_clone.rs:26:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:31:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:31:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = OsString::new().to_owned(); | ^^^^^^^^^^^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:33:29 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:33:29 +======= + --> $DIR/redundant_clone.rs:28:29 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:33:29 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:33:29 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:33:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:33:14 +======= + --> $DIR/redundant_clone.rs:28:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:33:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:33:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _s = OsString::new().to_os_string(); | ^^^^^^^^^^^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:44:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:44:19 +======= + --> $DIR/redundant_clone.rs:39:19 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:44:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:44:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _t = tup.0.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:44:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:44:14 +======= + --> $DIR/redundant_clone.rs:39:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:44:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:44:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _t = tup.0.clone(); | ^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:76:25 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:76:25 +======= + --> $DIR/redundant_clone.rs:71:25 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:76:25 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:76:25 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:76:24 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:76:24 +======= + --> $DIR/redundant_clone.rs:71:24 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:76:24 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:76:24 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if b { (a.clone(), a.clone()) } else { (Alpha, a) } | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/redundant_clone.rs:133:15 | LL | let _s = s.clone(); @@ -127,12 +457,39 @@ LL | let _s = s.clone(); | note: this value is dropped without further use --> $DIR/redundant_clone.rs:133:14 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) | LL | let _s = s.clone(); | ^ error: redundant clone --> $DIR/redundant_clone.rs:134:15 +<<<<<<< HEAD +======= +======= + --> $DIR/redundant_clone.rs:128:15 +>>>>>>> e29a68113 (Move redundant_clone to nursery) + | +LL | let _s = s.clone(); + | ^^^^^^^^ help: remove this + | +note: this value is dropped without further use + --> $DIR/redundant_clone.rs:134:14 +======= +>>>>>>> bfd5abad4 (Fix all the other tests) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + | +LL | let _s = s.clone(); + | ^ + +error: redundant clone + --> $DIR/redundant_clone.rs:134:15 +>>>>>>> 0567691cb (This commit resolves issue #10655) | LL | let _t = t.clone(); | ^^^^^^^^ help: remove this @@ -144,37 +501,133 @@ LL | let _t = t.clone(); | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:144:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:144:19 +======= + --> $DIR/redundant_clone.rs:139:19 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= --> $DIR/redundant_clone.rs:144:19 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:144:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _f = f.clone(); | ^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:144:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:144:18 +======= + --> $DIR/redundant_clone.rs:139:18 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= --> $DIR/redundant_clone.rs:144:18 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:144:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _f = f.clone(); | ^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:156:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:156:14 +======= + --> $DIR/redundant_clone.rs:151:14 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:156:14 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:156:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let y = x.clone().join("matthias"); | ^^^^^^^^ help: remove this | note: cloned value is neither consumed nor mutated +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:156:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:156:13 +======= + --> $DIR/redundant_clone.rs:151:13 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:156:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:156:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let y = x.clone().join("matthias"); | ^^^^^^^^^ error: redundant clone +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:210:11 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_clone.rs:210:11 +======= + --> $DIR/redundant_clone.rs:205:11 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:210:11 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_clone.rs:210:11 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | foo(&x.clone(), move || { | ^^^^^^^^ help: remove this | note: this value is dropped without further use +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:210:10 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_clone.rs:210:10 +======= + --> $DIR/redundant_clone.rs:205:10 +>>>>>>> e29a68113 (Move redundant_clone to nursery) +======= + --> $DIR/redundant_clone.rs:210:10 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_clone.rs:210:10 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | foo(&x.clone(), move || { | ^ diff --git a/tests/ui/redundant_closure_call_fixable.fixed b/tests/ui/redundant_closure_call_fixable.fixed index f3669a669ea1..a438f18b6bd9 100644 --- a/tests/ui/redundant_closure_call_fixable.fixed +++ b/tests/ui/redundant_closure_call_fixable.fixed @@ -78,6 +78,16 @@ fn issue9956() { || || || 42 } let _ = x()()()(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn bar() -> fn(i32, i32) { foo @@ -85,4 +95,15 @@ fn issue9956() { fn foo(_: i32, _: i32) {} bar()(42, 5); foo(42, 5); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_closure_call_fixable.rs b/tests/ui/redundant_closure_call_fixable.rs index db8c7f80df48..4bd6e40beb73 100644 --- a/tests/ui/redundant_closure_call_fixable.rs +++ b/tests/ui/redundant_closure_call_fixable.rs @@ -78,6 +78,16 @@ fn issue9956() { || || || 42 } let _ = x()()()(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn bar() -> fn(i32, i32) { foo @@ -85,4 +95,15 @@ fn issue9956() { fn foo(_: i32, _: i32) {} bar()((|| || 42)()(), 5); foo((|| || 42)()(), 5); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_closure_call_fixable.stderr b/tests/ui/redundant_closure_call_fixable.stderr index 618f5e071d6b..e3b254f9a1de 100644 --- a/tests/ui/redundant_closure_call_fixable.stderr +++ b/tests/ui/redundant_closure_call_fixable.stderr @@ -110,6 +110,16 @@ error: try not to call a closure in the expression where it is declared LL | let a = (|| echo!((|| 123)))()(); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try doing something like: `123` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: try not to call a closure in the expression where it is declared --> $DIR/redundant_closure_call_fixable.rs:86:11 | @@ -123,4 +133,16 @@ LL | foo((|| || 42)()(), 5); | ^^^^^^^^^^^^^^ help: try doing something like: `42` error: aborting due to 14 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 12 previous errors +>>>>>>> 7280ad9f7 ([`redundant_closure_call`]: handle nested closures) +======= +>>>>>>> 3fe2478ec (don't unnecessarily walk more in visitor and add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/redundant_pattern_matching_drop_order.fixed b/tests/ui/redundant_pattern_matching_drop_order.fixed index d1134de5ab47..079aa5cf9d4c 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.fixed +++ b/tests/ui/redundant_pattern_matching_drop_order.fixed @@ -2,12 +2,34 @@ // Issue #5746 #![warn(clippy::redundant_pattern_matching)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_if, clippy::needless_else )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_else)] +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::task::Poll::{Pending, Ready}; fn main() { diff --git a/tests/ui/redundant_pattern_matching_drop_order.rs b/tests/ui/redundant_pattern_matching_drop_order.rs index d144086e791a..5887255dbf24 100644 --- a/tests/ui/redundant_pattern_matching_drop_order.rs +++ b/tests/ui/redundant_pattern_matching_drop_order.rs @@ -2,12 +2,34 @@ // Issue #5746 #![warn(clippy::redundant_pattern_matching)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_if, clippy::needless_else )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::if_same_then_else, clippy::equatable_if_let, clippy::needless_else)] +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::task::Poll::{Pending, Ready}; fn main() { diff --git a/tests/ui/redundant_pattern_matching_option.fixed b/tests/ui/redundant_pattern_matching_option.fixed index a63ba5809e4b..805b0af717e8 100644 --- a/tests/ui/redundant_pattern_matching_option.fixed +++ b/tests/ui/redundant_pattern_matching_option.fixed @@ -48,7 +48,22 @@ fn main() { issue6067(); issue10726(); +<<<<<<< HEAD +<<<<<<< HEAD issue10803(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + issue10803(); +======= +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + issue10803(); +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + issue10803(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = if gen_opt().is_some() { 1 @@ -93,6 +108,14 @@ fn issue7921() { } fn issue10726() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let x = Some(42); x.is_some(); @@ -100,6 +123,13 @@ fn issue10726() { x.is_none(); x.is_none(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) x.is_some(); @@ -119,4 +149,43 @@ fn issue10803() { // Don't lint let _ = matches!(x, Some(16)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Some(42).is_some(); +======= + let x = Some(42); + let y = None::<()>; +>>>>>>> c53ceba56 (update tests) + + x.is_some(); + +<<<<<<< HEAD + None::<()>.is_some(); +<<<<<<< HEAD +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +======= + x.is_none(); +>>>>>>> c53ceba56 (update tests) + + y.is_some(); +======= +>>>>>>> 79a8867ad (update test option) + + x.is_some(); + + // Don't lint + match x { + Some(21) => true, + _ => false, + }; +>>>>>>> 342ce3da0 (fix reviewer comments) +======= +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_pattern_matching_option.rs b/tests/ui/redundant_pattern_matching_option.rs index 631f9091672d..0ee98c80f25d 100644 --- a/tests/ui/redundant_pattern_matching_option.rs +++ b/tests/ui/redundant_pattern_matching_option.rs @@ -57,7 +57,22 @@ fn main() { issue6067(); issue10726(); +<<<<<<< HEAD +<<<<<<< HEAD issue10803(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + issue10803(); +======= +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + issue10803(); +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + issue10803(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = if let Some(_) = gen_opt() { 1 @@ -108,21 +123,151 @@ fn issue7921() { } fn issue10726() { +<<<<<<< HEAD +<<<<<<< HEAD + let x = Some(42); + + match x { +======= +<<<<<<< HEAD +<<<<<<< HEAD + let x = Some(42); + + match x { +======= + match Some(42) { +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= let x = Some(42); match x { +>>>>>>> c53ceba56 (update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let x = Some(42); + + match x { +>>>>>>> 615b25c20 (Rebase attempt number 2) Some(_) => true, _ => false, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> c53ceba56 (update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + match x { + None => true, + _ => false, + }; + +<<<<<<< HEAD +<<<<<<< HEAD match x { +======= +<<<<<<< HEAD +<<<<<<< HEAD + match x { +======= + match Some(42) { +<<<<<<< HEAD +>>>>>>> afa2741e6 (redundant_pattern_matching) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + match x { +>>>>>>> 615b25c20 (Rebase attempt number 2) + Some(_) => false, + _ => true, + }; + + match x { +<<<<<<< HEAD +======= +<<<<<<< HEAD + match x { +======= + match Some(42) { +======= +>>>>>>> 342ce3da0 (fix reviewer comments) None => true, _ => false, }; +<<<<<<< HEAD + match Some(42) { +>>>>>>> afa2741e6 (redundant_pattern_matching) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + None => false, + _ => true, + }; + +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // Don't lint + match x { + Some(21) => true, + _ => false, + }; +} + +fn issue10803() { + let x = Some(42); + + let _ = matches!(x, Some(_)); + + let _ = matches!(x, None); + + // Don't lint + let _ = matches!(x, Some(16)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + match None::<()> { + Some(_) => false, + _ => true, + }; + + match None::<()> { + Some(_) => false, + _ => true, + }; + + match None::<()> { + None => true, + _ => false, + }; + + match None::<()> { + None => false, + _ => true, + }; +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + match None::<()> { +======= + match y { +>>>>>>> c53ceba56 (update tests) + Some(_) => true, + _ => false, +======= match x { Some(_) => false, _ => true, +>>>>>>> 79a8867ad (update test option) }; match x { @@ -135,6 +280,7 @@ fn issue10726() { Some(21) => true, _ => false, }; +>>>>>>> 342ce3da0 (fix reviewer comments) } fn issue10803() { @@ -146,4 +292,7 @@ fn issue10803() { // Don't lint let _ = matches!(x, Some(16)); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_pattern_matching_option.stderr b/tests/ui/redundant_pattern_matching_option.stderr index 097ca827a426..6b9df4e2cf78 100644 --- a/tests/ui/redundant_pattern_matching_option.stderr +++ b/tests/ui/redundant_pattern_matching_option.stderr @@ -77,49 +77,209 @@ LL | let _ = if let Some(_) = opt { true } else { false }; | -------^^^^^^^------ help: try: `if opt.is_some()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:62:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:62:20 +======= + --> $DIR/redundant_pattern_matching_option.rs:60:20 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:61:20 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:62:20 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:62:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = if let Some(_) = gen_opt() { | -------^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:64:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:64:19 +======= + --> $DIR/redundant_pattern_matching_option.rs:62:19 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:63:19 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:64:19 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_option.rs:64:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else if let None = gen_opt() { | -------^^^^------------ help: try: `if gen_opt().is_none()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:70:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:70:12 +======= + --> $DIR/redundant_pattern_matching_option.rs:68:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:69:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:70:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:70:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Some(..) = gen_opt() {} | -------^^^^^^^^------------ help: try: `if gen_opt().is_some()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:85:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:85:12 +======= + --> $DIR/redundant_pattern_matching_option.rs:83:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:84:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= --> $DIR/redundant_pattern_matching_option.rs:85:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:85:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Some(_) = Some(42) {} | -------^^^^^^^----------- help: try: `if Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:87:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:87:12 +======= + --> $DIR/redundant_pattern_matching_option.rs:85:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:86:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:87:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_option.rs:87:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let None = None::<()> {} | -------^^^^------------- help: try: `if None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:89:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:89:15 +======= + --> $DIR/redundant_pattern_matching_option.rs:87:15 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:88:15 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:89:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:89:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(_) = Some(42) {} | ----------^^^^^^^----------- help: try: `while Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:91:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:91:15 +======= + --> $DIR/redundant_pattern_matching_option.rs:89:15 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:90:15 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:91:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_option.rs:91:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let None = None::<()> {} | ----------^^^^------------- help: try: `while None::<()>.is_none()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:93:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:93:5 +======= + --> $DIR/redundant_pattern_matching_option.rs:91:5 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:92:5 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:93:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:93:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match Some(42) { LL | | Some(_) => true, @@ -128,7 +288,27 @@ LL | | }; | |_____^ help: try: `Some(42).is_some()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:98:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:98:5 +======= + --> $DIR/redundant_pattern_matching_option.rs:96:5 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:97:5 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:98:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:98:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match None::<()> { LL | | Some(_) => false, @@ -137,18 +317,69 @@ LL | | }; | |_____^ help: try: `None::<()>.is_none()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:106:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:106:12 +======= + --> $DIR/redundant_pattern_matching_option.rs:104:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:105:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:106:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_option.rs:106:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let None = *(&None::<()>) {} | -------^^^^----------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_none()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_option.rs:107:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_option.rs:107:12 +======= + --> $DIR/redundant_pattern_matching_option.rs:105:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_option.rs:106:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:107:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_option.rs:107:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let None = *&None::<()> {} | -------^^^^--------------- help: try: `if (&None::<()>).is_none()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/redundant_pattern_matching_option.rs:113:5 | LL | / match x { @@ -197,4 +428,92 @@ LL | let _ = matches!(x, None); | ^^^^^^^^^^^^^^^^^ help: try: `x.is_none()` error: aborting due to 28 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/redundant_pattern_matching_option.rs:109:5 +======= + --> $DIR/redundant_pattern_matching_option.rs:112:5 +>>>>>>> c53ceba56 (update tests) +======= + --> $DIR/redundant_pattern_matching_option.rs:111:5 +>>>>>>> 79a8867ad (update test option) +======= + --> $DIR/redundant_pattern_matching_option.rs:112:5 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_option.rs:113:5 +>>>>>>> 26f50395b (Add `needless_if` lint) + | +LL | / match x { +LL | | Some(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `x.is_some()` + +error: redundant pattern matching, consider using `is_none()` + --> $DIR/redundant_pattern_matching_option.rs:118:5 + | +LL | / match x { +LL | | None => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `x.is_none()` + +<<<<<<< HEAD +error: redundant pattern matching, consider using `is_some()` + --> $DIR/redundant_pattern_matching_option.rs:122:5 + | +LL | / match y { +LL | | Some(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try this: `y.is_some()` + +<<<<<<< HEAD +error: aborting due to 30 previous errors +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +======= +>>>>>>> 79a8867ad (update test option) +error: redundant pattern matching, consider using `is_none()` + --> $DIR/redundant_pattern_matching_option.rs:123:5 + | +LL | / match x { +LL | | Some(_) => false, +LL | | _ => true, +LL | | }; + | |_____^ help: try this: `x.is_none()` + +error: redundant pattern matching, consider using `is_some()` + --> $DIR/redundant_pattern_matching_option.rs:128:5 + | +LL | / match x { +LL | | None => false, +LL | | _ => true, +LL | | }; + | |_____^ help: try this: `x.is_some()` + +<<<<<<< HEAD +error: aborting due to 26 previous errors +>>>>>>> 342ce3da0 (fix reviewer comments) +======= +error: redundant pattern matching, consider using `is_some()` + --> $DIR/redundant_pattern_matching_option.rs:143:13 + | +LL | let _ = matches!(x, Some(_)); + | ^^^^^^^^^^^^^^^^^^^^ help: try this: `x.is_some()` + +error: redundant pattern matching, consider using `is_none()` + --> $DIR/redundant_pattern_matching_option.rs:145:13 + | +LL | let _ = matches!(x, None); + | ^^^^^^^^^^^^^^^^^ help: try this: `x.is_none()` + +error: aborting due to 28 previous errors +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/redundant_pattern_matching_result.fixed b/tests/ui/redundant_pattern_matching_result.fixed index 343e0d04340d..e12dd5276c9c 100644 --- a/tests/ui/redundant_pattern_matching_result.fixed +++ b/tests/ui/redundant_pattern_matching_result.fixed @@ -45,7 +45,22 @@ fn main() { issue6067(); issue6065(); issue10726(); +<<<<<<< HEAD +<<<<<<< HEAD issue10803(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + issue10803(); +======= +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + issue10803(); +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + issue10803(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = if gen_res().is_ok() { 1 @@ -112,6 +127,14 @@ const fn issue6067() { } fn issue10726() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // This is optional, but it makes the examples easier let x: Result = Ok(42); @@ -148,4 +171,50 @@ fn issue10803() { // Don't lint let _ = matches!(x, Err(16)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + Ok::(42).is_ok(); +======= + // This is optional, but it makes the examples easier + let x: Result = Ok(42); +>>>>>>> 3991dd10b (fix reviewer comments: tests results) + + x.is_ok(); + + x.is_err(); + + x.is_err(); + +<<<<<<< HEAD +<<<<<<< HEAD + Err::(42).is_ok(); +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + match Ok::(42) { + Ok(21) => true, + _ => false, +======= + x.is_ok(); + + // Don't lint + match x { + Err(16) => false, + _ => true, + }; + + // Don't lint + match x { + Ok(16) => false, + _ => true, +>>>>>>> 3991dd10b (fix reviewer comments: tests results) + }; +>>>>>>> 342ce3da0 (fix reviewer comments) +======= +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_pattern_matching_result.rs b/tests/ui/redundant_pattern_matching_result.rs index 4d64eafe590c..6aa39b2214dc 100644 --- a/tests/ui/redundant_pattern_matching_result.rs +++ b/tests/ui/redundant_pattern_matching_result.rs @@ -57,7 +57,22 @@ fn main() { issue6067(); issue6065(); issue10726(); +<<<<<<< HEAD +<<<<<<< HEAD issue10803(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + issue10803(); +======= +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + issue10803(); +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + issue10803(); +>>>>>>> 615b25c20 (Rebase attempt number 2) let _ = if let Ok(_) = gen_res() { 1 @@ -130,19 +145,66 @@ const fn issue6067() { } fn issue10726() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 3991dd10b (fix reviewer comments: tests results) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // This is optional, but it makes the examples easier let x: Result = Ok(42); match x { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + match Ok::(42) { +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +>>>>>>> 3991dd10b (fix reviewer comments: tests results) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) Ok(_) => true, _ => false, }; +<<<<<<< HEAD +<<<<<<< HEAD + match x { +======= +<<<<<<< HEAD +<<<<<<< HEAD match x { +======= + match Ok::(42) { +<<<<<<< HEAD +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + match x { +>>>>>>> 3991dd10b (fix reviewer comments: tests results) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + match x { +>>>>>>> 615b25c20 (Rebase attempt number 2) Ok(_) => false, _ => true, }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) match x { Err(_) => true, _ => false, @@ -178,4 +240,49 @@ fn issue10803() { // Don't lint let _ = matches!(x, Err(16)); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + match Err::(42) { + Ok(_) => false, + _ => true, + }; + + match Err::(42) { + Ok(_) => true, + _ => false, + }; +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +======= + match x { +>>>>>>> 3991dd10b (fix reviewer comments: tests results) + Err(_) => true, + _ => false, + }; + + match x { + Err(_) => false, + _ => true, + }; + + // Don't lint + match x { + Err(16) => false, + _ => true, + }; + + // Don't lint + match x { + Ok(16) => false, + _ => true, + }; +>>>>>>> 342ce3da0 (fix reviewer comments) +======= +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/redundant_pattern_matching_result.stderr b/tests/ui/redundant_pattern_matching_result.stderr index 2b1ce9f54652..9ae74ba693df 100644 --- a/tests/ui/redundant_pattern_matching_result.stderr +++ b/tests/ui/redundant_pattern_matching_result.stderr @@ -73,67 +73,287 @@ LL | let _ = if let Ok(_) = Ok::(4) { true } else { false }; | -------^^^^^--------------------- help: try: `if Ok::(4).is_ok()` error: redundant pattern matching, consider using `is_ok()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:62:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:62:20 +======= + --> $DIR/redundant_pattern_matching_result.rs:60:20 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:61:20 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:62:20 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:62:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = if let Ok(_) = gen_res() { | -------^^^^^------------ help: try: `if gen_res().is_ok()` error: redundant pattern matching, consider using `is_err()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:64:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:64:19 +======= + --> $DIR/redundant_pattern_matching_result.rs:62:19 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:63:19 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:64:19 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_result.rs:64:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else if let Err(_) = gen_res() { | -------^^^^^^------------ help: try: `if gen_res().is_err()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:87:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:87:19 +======= + --> $DIR/redundant_pattern_matching_result.rs:85:19 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:86:19 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:87:19 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:87:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(_) = r#try!(result_opt()) {} | ----------^^^^^^^----------------------- help: try: `while r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:88:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:88:16 +======= + --> $DIR/redundant_pattern_matching_result.rs:86:16 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:87:16 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:88:16 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_result.rs:88:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Some(_) = r#try!(result_opt()) {} | -------^^^^^^^----------------------- help: try: `if r#try!(result_opt()).is_some()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:94:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:94:12 +======= + --> $DIR/redundant_pattern_matching_result.rs:92:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:93:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:94:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:94:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Some(_) = m!() {} | -------^^^^^^^------- help: try: `if m!().is_some()` error: redundant pattern matching, consider using `is_some()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:95:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:95:15 +======= + --> $DIR/redundant_pattern_matching_result.rs:93:15 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:94:15 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:95:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_result.rs:95:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(_) = m!() {} | ----------^^^^^^^------- help: try: `while m!().is_some()` error: redundant pattern matching, consider using `is_ok()` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:113:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:113:12 +======= + --> $DIR/redundant_pattern_matching_result.rs:111:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:112:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:113:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:113:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Ok(_) = Ok::(42) {} | -------^^^^^--------------------- help: try: `if Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:115:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:115:12 +======= + --> $DIR/redundant_pattern_matching_result.rs:113:12 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:114:12 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= --> $DIR/redundant_pattern_matching_result.rs:115:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:115:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Err(_) = Err::(42) {} | -------^^^^^^---------------------- help: try: `if Err::(42).is_err()` error: redundant pattern matching, consider using `is_ok()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:117:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:117:15 +======= + --> $DIR/redundant_pattern_matching_result.rs:115:15 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:116:15 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= --> $DIR/redundant_pattern_matching_result.rs:117:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:117:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Ok(_) = Ok::(10) {} | ----------^^^^^--------------------- help: try: `while Ok::(10).is_ok()` error: redundant pattern matching, consider using `is_err()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:119:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:119:15 +======= + --> $DIR/redundant_pattern_matching_result.rs:117:15 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:118:15 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:119:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_pattern_matching_result.rs:119:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Err(_) = Ok::(10) {} | ----------^^^^^^--------------------- help: try: `while Ok::(10).is_err()` error: redundant pattern matching, consider using `is_ok()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:121:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:121:5 +======= + --> $DIR/redundant_pattern_matching_result.rs:119:5 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:120:5 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:121:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:121:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match Ok::(42) { LL | | Ok(_) => true, @@ -142,13 +362,63 @@ LL | | }; | |_____^ help: try: `Ok::(42).is_ok()` error: redundant pattern matching, consider using `is_err()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_pattern_matching_result.rs:126:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_pattern_matching_result.rs:126:5 +======= + --> $DIR/redundant_pattern_matching_result.rs:124:5 +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= + --> $DIR/redundant_pattern_matching_result.rs:125:5 +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +======= + --> $DIR/redundant_pattern_matching_result.rs:126:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_pattern_matching_result.rs:126:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match Err::(42) { LL | | Ok(_) => false, LL | | Err(_) => true, LL | | }; | |_____^ help: try: `Err::(42).is_err()` +<<<<<<< HEAD + +error: redundant pattern matching, consider using `is_ok()` + --> $DIR/redundant_pattern_matching_result.rs:136:5 + | +LL | / match x { +LL | | Ok(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try: `x.is_ok()` + +error: redundant pattern matching, consider using `is_err()` + --> $DIR/redundant_pattern_matching_result.rs:141:5 + | +LL | / match x { +LL | | Ok(_) => false, +LL | | _ => true, +LL | | }; + | |_____^ help: try: `x.is_err()` + +error: redundant pattern matching, consider using `is_err()` + --> $DIR/redundant_pattern_matching_result.rs:146:5 + | +LL | / match x { +LL | | Err(_) => true, +LL | | _ => false, +LL | | }; + | |_____^ help: try: `x.is_err()` + +======= error: redundant pattern matching, consider using `is_ok()` --> $DIR/redundant_pattern_matching_result.rs:136:5 @@ -199,4 +469,59 @@ LL | let _ = matches!(x, Err(_)); | ^^^^^^^^^^^^^^^^^^^ help: try: `x.is_err()` error: aborting due to 28 previous errors +<<<<<<< HEAD +======= +LL | / match Err::(42) { +LL | | Ok(_) => false, +LL | | _ => true, +LL | | }; + | |_____^ help: try this: `Err::(42).is_err()` + +======= +>>>>>>> 342ce3da0 (fix reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +error: redundant pattern matching, consider using `is_ok()` + --> $DIR/redundant_pattern_matching_result.rs:151:5 + | +LL | / match x { +LL | | Err(_) => false, +LL | | _ => true, +LL | | }; +<<<<<<< HEAD + | |_____^ help: try: `x.is_ok()` + +======= + | |_____^ help: try this: `x.is_ok()` + +<<<<<<< HEAD +error: aborting due to 26 previous errors +>>>>>>> afa2741e6 (redundant_pattern_matching) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +error: redundant pattern matching, consider using `is_ok()` + --> $DIR/redundant_pattern_matching_result.rs:172:13 + | +LL | let _ = matches!(x, Ok(_)); +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^ help: try: `x.is_ok()` +======= + | ^^^^^^^^^^^^^^^^^^ help: try this: `x.is_ok()` +>>>>>>> 0567691cb (This commit resolves issue #10655) + +error: redundant pattern matching, consider using `is_err()` + --> $DIR/redundant_pattern_matching_result.rs:174:13 + | +LL | let _ = matches!(x, Err(_)); +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^ help: try: `x.is_err()` + +error: aborting due to 28 previous errors +======= + | ^^^^^^^^^^^^^^^^^^^ help: try this: `x.is_err()` + +error: aborting due to 28 previous errors +>>>>>>> 0b507c6f0 (redundant pattern matches! result) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/redundant_type_annotations.rs b/tests/ui/redundant_type_annotations.rs index cc507b8d658c..6c3d3b6988fe 100644 --- a/tests/ui/redundant_type_annotations.rs +++ b/tests/ui/redundant_type_annotations.rs @@ -18,6 +18,16 @@ fn plus_one>(val: T) -> T { val + 1 } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[derive(Default)] struct Slice { inner: u32, @@ -27,6 +37,19 @@ struct Slice { struct Pie { inner: u32, inner_struct: Slice, +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +struct Pie { + inner: u32, +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } enum Pizza { @@ -39,7 +62,23 @@ fn return_a_string() -> String { } fn return_a_struct() -> Pie { +<<<<<<< HEAD +<<<<<<< HEAD + Pie::default() +======= +<<<<<<< HEAD +<<<<<<< HEAD + Pie::default() +======= + Pie { inner: 5 } +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= Pie::default() +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + Pie::default() +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn return_an_enum() -> Pizza { @@ -55,6 +94,16 @@ impl Pie { self.inner } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn return_a_ref(&self) -> &u32 { &self.inner } @@ -63,12 +112,39 @@ impl Pie { &self.inner_struct } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn associated_return_an_int() -> u32 { 5 } fn new() -> Self { +<<<<<<< HEAD +<<<<<<< HEAD + Self::default() +======= +<<<<<<< HEAD +<<<<<<< HEAD + Self::default() +======= + Self { inner: 5 } +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= Self::default() +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + Self::default() +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn associated_return_a_string() -> String { @@ -76,11 +152,33 @@ impl Pie { } fn test_method_call(&self) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Everything here should be lint let v: u32 = self.return_an_int(); let v: &u32 = self.return_a_ref(); let v: &Slice = self.return_a_ref_to_struct(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + let v: u32 = self.return_an_int(); // Should lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } } @@ -91,17 +189,72 @@ fn test_generics() { // The type annotation is needed to determine the topic let _c: Cake = make_cake(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // This could be lint, but currently doesn't + let _c: Cake = make_cake::(); + + // This could be lint, but currently doesn't + let _c: u8 = make_something::(); + // This could be lint, but currently doesn't +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // This should lint (doesn't) +======= + // This could be lint, but currently doesn't +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) let _c: Cake = make_cake::(); // This could be lint, but currently doesn't let _c: u8 = make_something::(); +<<<<<<< HEAD + // This should lint (doesn't) +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= // This could be lint, but currently doesn't +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _c: u8 = plus_one(5_u8); // Annotation needed otherwise T is i32 let _c: u8 = plus_one(5); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + + // This could be lint, but currently doesn't + let _return: String = String::from("test"); +} + +fn test_non_locals() { + // This shouldn't be lint +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +} + +fn test_non_locals() { + // This shouldn't lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= // This could be lint, but currently doesn't let _return: String = String::from("test"); @@ -109,6 +262,10 @@ fn test_generics() { fn test_non_locals() { // This shouldn't be lint +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn _arg(x: u32) -> u32 { x } @@ -118,7 +275,38 @@ fn test_non_locals() { } fn test_complex_types() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // Shouldn't be lint, since the literal will be i32 otherwise + let _u8: u8 = 128; + + // This could be lint, but currently doesn't + let _tuple_i32: (i32, i32) = (12, 13); + + // Shouldn't be lint, since the tuple will be i32 otherwise + let _tuple_u32: (u32, u32) = (1, 2); + + // Should be lint, since the type is determined by the init value, but currently doesn't + let _tuple_u32: (u32, u32) = (3_u32, 4_u32); + + // This could be lint, but currently doesn't + let _array: [i32; 3] = [5, 6, 7]; + + // Shouldn't be lint +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + // Shouldn't lint, since the literal will be i32 otherwise +======= // Shouldn't be lint, since the literal will be i32 otherwise +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) let _u8: u8 = 128; // This could be lint, but currently doesn't @@ -133,12 +321,36 @@ fn test_complex_types() { // This could be lint, but currently doesn't let _array: [i32; 3] = [5, 6, 7]; +<<<<<<< HEAD + // Shouldn't lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= // Shouldn't be lint +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _array: [u32; 2] = [8, 9]; } fn test_functions() { +<<<<<<< HEAD +<<<<<<< HEAD + // Everything here should be lint +======= +<<<<<<< HEAD +<<<<<<< HEAD // Everything here should be lint +======= + // Everything here should lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + // Everything here should be lint +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // Everything here should be lint +>>>>>>> 615b25c20 (Rebase attempt number 2) let _return: String = return_a_string(); @@ -154,14 +366,52 @@ fn test_functions() { let _return: u32 = new_pie.return_an_int(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + let _return: String = String::from("test"); + +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _return: u32 = Pie::associated_return_an_int(); let _return: String = Pie::associated_return_a_string(); } fn test_simple_types() { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + // Everything here should be lint + + let _var: u32 = u32::MAX; + + let _var: u32 = 5_u32; + + let _var: &str = "test"; + + let _var: &[u8] = b"test"; + +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= // Everything here should be lint +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) let _var: u32 = u32::MAX; let _var: u32 = 5_u32; @@ -170,7 +420,29 @@ fn test_simple_types() { let _var: &[u8] = b"test"; +<<<<<<< HEAD + // Should lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _var: bool = false; } fn main() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + +// TODO: test refs +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/redundant_type_annotations.stderr b/tests/ui/redundant_type_annotations.stderr index e8b2fe5c3847..bb8b8471deba 100644 --- a/tests/ui/redundant_type_annotations.stderr +++ b/tests/ui/redundant_type_annotations.stderr @@ -1,12 +1,46 @@ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:81:9 | LL | let v: u32 = self.return_an_int(); +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:81:9 + | +LL | let v: u32 = self.return_an_int(); +======= + --> $DIR/redundant_type_annotations.rs:64:9 + | +LL | let v: u32 = self.return_an_int(); // Should lint +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:81:9 + | +LL | let v: u32 = self.return_an_int(); +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:81:9 + | +LL | let v: u32 = self.return_an_int(); +>>>>>>> 615b25c20 (Rebase attempt number 2) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::redundant-type-annotations` implied by `-D warnings` error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/redundant_type_annotations.rs:82:9 | LL | let v: &u32 = self.return_a_ref(); @@ -20,87 +54,323 @@ LL | let v: &Slice = self.return_a_ref_to_struct(); error: redundant type annotation --> $DIR/redundant_type_annotations.rs:143:5 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + --> $DIR/redundant_type_annotations.rs:121:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: String = return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:145:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:145:5 +======= + --> $DIR/redundant_type_annotations.rs:123:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:145:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:145:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: Pie = return_a_struct(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:147:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:147:5 +======= + --> $DIR/redundant_type_annotations.rs:125:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:147:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:147:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: Pizza = return_an_enum(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:149:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:149:5 +======= + --> $DIR/redundant_type_annotations.rs:127:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= --> $DIR/redundant_type_annotations.rs:149:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:149:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: u32 = return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:151:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:151:5 +======= + --> $DIR/redundant_type_annotations.rs:129:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= --> $DIR/redundant_type_annotations.rs:151:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:151:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: String = String::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:153:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:153:5 +======= + --> $DIR/redundant_type_annotations.rs:131:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:153:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_type_annotations.rs:153:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let new_pie: Pie = Pie::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:155:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:155:5 +======= + --> $DIR/redundant_type_annotations.rs:133:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:155:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/redundant_type_annotations.rs:155:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: u32 = new_pie.return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:157:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:157:5 +======= + --> $DIR/redundant_type_annotations.rs:137:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:157:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:157:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: u32 = Pie::associated_return_an_int(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:159:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:159:5 +======= + --> $DIR/redundant_type_annotations.rs:139:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:159:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:159:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _return: String = Pie::associated_return_a_string(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:165:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:165:5 +======= + --> $DIR/redundant_type_annotations.rs:143:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:165:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:165:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _var: u32 = u32::MAX; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:167:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:167:5 +======= + --> $DIR/redundant_type_annotations.rs:146:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:167:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:167:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _var: u32 = 5_u32; | ^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:169:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:169:5 +======= + --> $DIR/redundant_type_annotations.rs:149:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:169:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:169:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _var: &str = "test"; | ^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:171:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:171:5 +======= + --> $DIR/redundant_type_annotations.rs:152:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:171:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:171:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _var: &[u8] = b"test"; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: redundant type annotation +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/redundant_type_annotations.rs:173:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/redundant_type_annotations.rs:173:5 +======= + --> $DIR/redundant_type_annotations.rs:155:5 +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= + --> $DIR/redundant_type_annotations.rs:173:5 +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/redundant_type_annotations.rs:173:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _var: bool = false; | ^^^^^^^^^^^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 17 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 17 previous errors +======= +error: aborting due to 15 previous errors +>>>>>>> 01b105725 (Add redundant type annotations lint) +======= +error: aborting due to 17 previous errors +>>>>>>> 29ab954a2 (Add support to returned refs from `MethodCall`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 17 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/regex.rs b/tests/ui/regex.rs index 89d1d9494545..94b5154a25fd 100644 --- a/tests/ui/regex.rs +++ b/tests/ui/regex.rs @@ -1,9 +1,34 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( unused, clippy::needless_raw_strings, clippy::needless_raw_string_hashes, clippy::needless_borrow )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +#![allow(unused, clippy::needless_raw_string_hashes, clippy::needless_borrow)] +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +#![allow( + unused, + clippy::needless_raw_strings, + clippy::needless_raw_string_hashes, + clippy::needless_borrow +)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::invalid_regex, clippy::trivial_regex)] extern crate regex; diff --git a/tests/ui/regex.stderr b/tests/ui/regex.stderr index 21f1cb44460e..c10c97d61ad9 100644 --- a/tests/ui/regex.stderr +++ b/tests/ui/regex.stderr @@ -86,7 +86,23 @@ error: regex parse error: /b/c ^^ error: unrecognized escape sequence +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:47:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:47:42 +======= + --> $DIR/regex.rs:42:42 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:47:42 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:47:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let escaped_string_span = Regex::new("//b//c"); | ^^^^^^^^ @@ -94,19 +110,71 @@ LL | let escaped_string_span = Regex::new("//b//c"); = help: consider using a raw string literal: `r".."` error: regex syntax error: duplicate flag +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:49:34 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:49:34 +======= + --> $DIR/regex.rs:44:34 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:49:34 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/regex.rs:49:34 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let aux_span = Regex::new("(?ixi)"); | ^ ^ error: regex syntax error: pattern can match invalid UTF-8 +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:54:53 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:54:53 +======= + --> $DIR/regex.rs:49:53 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:54:53 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:54:53 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let invalid_utf8_should_lint = Regex::new("(?-u)."); | ^ error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:58:33 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:58:33 +======= + --> $DIR/regex.rs:48:33 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:53:33 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:58:33 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/regex.rs:58:33 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_eq = Regex::new("^foobar$"); | ^^^^^^^^^^ @@ -114,7 +182,27 @@ LL | let trivial_eq = Regex::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:60:48 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:60:48 +======= + --> $DIR/regex.rs:50:48 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:55:48 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:60:48 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:60:48 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); | ^^^^^^^^^^ @@ -122,7 +210,27 @@ LL | let trivial_eq_builder = RegexBuilder::new("^foobar$"); = help: consider using `==` on `str`s error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:62:42 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:62:42 +======= + --> $DIR/regex.rs:52:42 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:57:42 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:62:42 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/regex.rs:62:42 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_starts_with = Regex::new("^foobar"); | ^^^^^^^^^ @@ -130,7 +238,27 @@ LL | let trivial_starts_with = Regex::new("^foobar"); = help: consider using `str::starts_with` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:64:40 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:64:40 +======= + --> $DIR/regex.rs:54:40 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:59:40 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:64:40 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:64:40 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_ends_with = Regex::new("foobar$"); | ^^^^^^^^^ @@ -138,7 +266,27 @@ LL | let trivial_ends_with = Regex::new("foobar$"); = help: consider using `str::ends_with` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:66:39 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:66:39 +======= + --> $DIR/regex.rs:56:39 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:61:39 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= --> $DIR/regex.rs:66:39 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:66:39 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_contains = Regex::new("foobar"); | ^^^^^^^^ @@ -146,7 +294,27 @@ LL | let trivial_contains = Regex::new("foobar"); = help: consider using `str::contains` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:68:39 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:68:39 +======= + --> $DIR/regex.rs:58:39 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:63:39 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= --> $DIR/regex.rs:68:39 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:68:39 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); | ^^^^^^^^^^^^^^^^ @@ -154,7 +322,27 @@ LL | let trivial_contains = Regex::new(NOT_A_REAL_REGEX); = help: consider using `str::contains` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:70:40 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:70:40 +======= + --> $DIR/regex.rs:60:40 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:65:40 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= --> $DIR/regex.rs:70:40 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:70:40 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_backslash = Regex::new("a//.b"); | ^^^^^^^ @@ -162,7 +350,27 @@ LL | let trivial_backslash = Regex::new("a//.b"); = help: consider using `str::contains` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:73:36 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:73:36 +======= + --> $DIR/regex.rs:63:36 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:68:36 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= --> $DIR/regex.rs:73:36 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:73:36 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_empty = Regex::new(""); | ^^ @@ -170,7 +378,27 @@ LL | let trivial_empty = Regex::new(""); = help: the regex is unlikely to be useful as it is error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:75:36 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:75:36 +======= + --> $DIR/regex.rs:65:36 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:70:36 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:75:36 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:75:36 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_empty = Regex::new("^"); | ^^^ @@ -178,7 +406,27 @@ LL | let trivial_empty = Regex::new("^"); = help: the regex is unlikely to be useful as it is error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:77:36 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:77:36 +======= + --> $DIR/regex.rs:67:36 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:72:36 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:77:36 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:77:36 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let trivial_empty = Regex::new("^$"); | ^^^^ @@ -186,12 +434,48 @@ LL | let trivial_empty = Regex::new("^$"); = help: consider using `str::is_empty` error: trivial regex +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/regex.rs:79:44 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/regex.rs:79:44 +======= + --> $DIR/regex.rs:69:44 +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= + --> $DIR/regex.rs:74:44 +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +======= + --> $DIR/regex.rs:79:44 +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/regex.rs:79:44 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let binary_trivial_empty = BRegex::new("^$"); | ^^^^ | = help: consider using `str::is_empty` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 24 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 24 previous errors +======= +error: aborting due to 23 previous errors +>>>>>>> 5fc1c7901 (bump up `regex-syntax` dependency version to 0.7.0) +======= +error: aborting due to 24 previous errors +>>>>>>> ffc2bc83b (Fixing `invalid_regex` with invalid UTF8. Also, adding more test cases) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 24 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/rename.stderr b/tests/ui/rename.stderr index 783608a08410..8b16dfe23224 100644 --- a/tests/ui/rename.stderr +++ b/tests/ui/rename.stderr @@ -1,5 +1,15 @@ error: lint `clippy::almost_complete_letter_range` has been renamed to `clippy::almost_complete_range` --> $DIR/rename.rs:53:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:53:9 +======= + --> $DIR/rename.rs:44:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::almost_complete_letter_range)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::almost_complete_range` @@ -8,168 +18,448 @@ LL | #![warn(clippy::almost_complete_letter_range)] error: lint `clippy::blacklisted_name` has been renamed to `clippy::disallowed_names` --> $DIR/rename.rs:54:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:54:9 +======= + --> $DIR/rename.rs:45:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::blacklisted_name)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_names` error: lint `clippy::block_in_if_condition_expr` has been renamed to `clippy::blocks_in_if_conditions` --> $DIR/rename.rs:55:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:55:9 +======= + --> $DIR/rename.rs:46:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::block_in_if_condition_expr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::block_in_if_condition_stmt` has been renamed to `clippy::blocks_in_if_conditions` --> $DIR/rename.rs:56:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:56:9 +======= + --> $DIR/rename.rs:47:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::block_in_if_condition_stmt)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::blocks_in_if_conditions` error: lint `clippy::box_vec` has been renamed to `clippy::box_collection` --> $DIR/rename.rs:57:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:57:9 +======= + --> $DIR/rename.rs:48:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::box_vec)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::box_collection` error: lint `clippy::const_static_lifetime` has been renamed to `clippy::redundant_static_lifetimes` --> $DIR/rename.rs:58:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:58:9 +======= + --> $DIR/rename.rs:49:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::const_static_lifetime)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::redundant_static_lifetimes` error: lint `clippy::cyclomatic_complexity` has been renamed to `clippy::cognitive_complexity` --> $DIR/rename.rs:59:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:59:9 +======= + --> $DIR/rename.rs:50:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::cyclomatic_complexity)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::cognitive_complexity` error: lint `clippy::derive_hash_xor_eq` has been renamed to `clippy::derived_hash_with_manual_eq` --> $DIR/rename.rs:60:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:60:9 +======= + --> $DIR/rename.rs:51:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::derive_hash_xor_eq)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::derived_hash_with_manual_eq` error: lint `clippy::disallowed_method` has been renamed to `clippy::disallowed_methods` --> $DIR/rename.rs:61:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:61:9 +======= + --> $DIR/rename.rs:52:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::disallowed_method)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_methods` error: lint `clippy::disallowed_type` has been renamed to `clippy::disallowed_types` --> $DIR/rename.rs:62:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:62:9 +======= + --> $DIR/rename.rs:53:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::disallowed_type)] | ^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::disallowed_types` error: lint `clippy::eval_order_dependence` has been renamed to `clippy::mixed_read_write_in_expression` --> $DIR/rename.rs:63:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:63:9 +======= + --> $DIR/rename.rs:54:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::eval_order_dependence)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::mixed_read_write_in_expression` error: lint `clippy::identity_conversion` has been renamed to `clippy::useless_conversion` --> $DIR/rename.rs:64:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:64:9 +======= + --> $DIR/rename.rs:55:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::identity_conversion)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::useless_conversion` error: lint `clippy::if_let_some_result` has been renamed to `clippy::match_result_ok` --> $DIR/rename.rs:65:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:65:9 +======= + --> $DIR/rename.rs:56:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::if_let_some_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::match_result_ok` error: lint `clippy::integer_arithmetic` has been renamed to `clippy::arithmetic_side_effects` --> $DIR/rename.rs:66:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:66:9 +======= + --> $DIR/rename.rs:57:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::integer_arithmetic)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::arithmetic_side_effects` error: lint `clippy::logic_bug` has been renamed to `clippy::overly_complex_bool_expr` --> $DIR/rename.rs:67:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:67:9 +======= + --> $DIR/rename.rs:58:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::logic_bug)] | ^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::overly_complex_bool_expr` error: lint `clippy::new_without_default_derive` has been renamed to `clippy::new_without_default` --> $DIR/rename.rs:68:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:68:9 +======= + --> $DIR/rename.rs:59:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::new_without_default_derive)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::new_without_default` error: lint `clippy::option_and_then_some` has been renamed to `clippy::bind_instead_of_map` --> $DIR/rename.rs:69:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:69:9 +======= + --> $DIR/rename.rs:60:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::option_and_then_some)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::bind_instead_of_map` error: lint `clippy::option_expect_used` has been renamed to `clippy::expect_used` --> $DIR/rename.rs:70:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:70:9 +======= + --> $DIR/rename.rs:61:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::option_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::option_map_unwrap_or` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:71:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:71:9 +======= + --> $DIR/rename.rs:62:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::option_map_unwrap_or)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:72:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:72:9 +======= + --> $DIR/rename.rs:63:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::option_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::option_unwrap_used` has been renamed to `clippy::unwrap_used` --> $DIR/rename.rs:73:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:73:9 +======= + --> $DIR/rename.rs:64:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::option_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::ref_in_deref` has been renamed to `clippy::needless_borrow` --> $DIR/rename.rs:74:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:74:9 +======= + --> $DIR/rename.rs:65:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::ref_in_deref)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::needless_borrow` error: lint `clippy::result_expect_used` has been renamed to `clippy::expect_used` --> $DIR/rename.rs:75:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:75:9 +======= + --> $DIR/rename.rs:66:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::result_expect_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::expect_used` error: lint `clippy::result_map_unwrap_or_else` has been renamed to `clippy::map_unwrap_or` --> $DIR/rename.rs:76:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:76:9 +======= + --> $DIR/rename.rs:67:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::result_map_unwrap_or_else)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::map_unwrap_or` error: lint `clippy::result_unwrap_used` has been renamed to `clippy::unwrap_used` --> $DIR/rename.rs:77:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:77:9 +======= + --> $DIR/rename.rs:68:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::result_unwrap_used)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::unwrap_used` error: lint `clippy::single_char_push_str` has been renamed to `clippy::single_char_add_str` --> $DIR/rename.rs:78:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:78:9 +======= + --> $DIR/rename.rs:69:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::single_char_push_str)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::single_char_add_str` error: lint `clippy::stutter` has been renamed to `clippy::module_name_repetitions` --> $DIR/rename.rs:79:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:79:9 +======= + --> $DIR/rename.rs:70:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::stutter)] | ^^^^^^^^^^^^^^^ help: use the new name: `clippy::module_name_repetitions` error: lint `clippy::to_string_in_display` has been renamed to `clippy::recursive_format_impl` --> $DIR/rename.rs:80:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:80:9 +======= + --> $DIR/rename.rs:71:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::to_string_in_display)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::recursive_format_impl` error: lint `clippy::zero_width_space` has been renamed to `clippy::invisible_characters` --> $DIR/rename.rs:81:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:81:9 +======= + --> $DIR/rename.rs:72:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::zero_width_space)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `clippy::invisible_characters` @@ -182,6 +472,16 @@ LL | #![warn(clippy::cast_ref_to_mut)] error: lint `clippy::clone_double_ref` has been renamed to `suspicious_double_ref_op` --> $DIR/rename.rs:83:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:83:9 +======= + --> $DIR/rename.rs:73:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::clone_double_ref)] | ^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `suspicious_double_ref_op` @@ -194,6 +494,16 @@ LL | #![warn(clippy::cmp_nan)] error: lint `clippy::drop_bounds` has been renamed to `drop_bounds` --> $DIR/rename.rs:85:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:85:9 +======= + --> $DIR/rename.rs:74:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::drop_bounds)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `drop_bounds` @@ -212,18 +522,48 @@ LL | #![warn(clippy::drop_ref)] error: lint `clippy::for_loop_over_option` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:88:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:88:9 +======= + --> $DIR/rename.rs:75:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::for_loop_over_option)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loop_over_result` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:89:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:89:9 +======= + --> $DIR/rename.rs:76:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::for_loop_over_result)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` error: lint `clippy::for_loops_over_fallibles` has been renamed to `for_loops_over_fallibles` --> $DIR/rename.rs:90:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:90:9 +======= + --> $DIR/rename.rs:77:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::for_loops_over_fallibles)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `for_loops_over_fallibles` @@ -248,18 +588,48 @@ LL | #![warn(clippy::fn_null_check)] error: lint `clippy::into_iter_on_array` has been renamed to `array_into_iter` --> $DIR/rename.rs:94:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:94:9 +======= + --> $DIR/rename.rs:78:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::into_iter_on_array)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `array_into_iter` error: lint `clippy::invalid_atomic_ordering` has been renamed to `invalid_atomic_ordering` --> $DIR/rename.rs:95:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:95:9 +======= + --> $DIR/rename.rs:79:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::invalid_atomic_ordering)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_atomic_ordering` error: lint `clippy::invalid_ref` has been renamed to `invalid_value` --> $DIR/rename.rs:96:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:96:9 +======= + --> $DIR/rename.rs:80:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::invalid_ref)] | ^^^^^^^^^^^^^^^^^^^ help: use the new name: `invalid_value` @@ -272,30 +642,80 @@ LL | #![warn(clippy::invalid_utf8_in_unchecked)] error: lint `clippy::let_underscore_drop` has been renamed to `let_underscore_drop` --> $DIR/rename.rs:98:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:98:9 +======= + --> $DIR/rename.rs:81:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::let_underscore_drop)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `let_underscore_drop` error: lint `clippy::mem_discriminant_non_enum` has been renamed to `enum_intrinsics_non_enums` --> $DIR/rename.rs:99:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:99:9 +======= + --> $DIR/rename.rs:82:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::mem_discriminant_non_enum)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `enum_intrinsics_non_enums` error: lint `clippy::panic_params` has been renamed to `non_fmt_panics` --> $DIR/rename.rs:100:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:100:9 +======= + --> $DIR/rename.rs:83:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::panic_params)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `non_fmt_panics` error: lint `clippy::positional_named_format_parameters` has been renamed to `named_arguments_used_positionally` --> $DIR/rename.rs:101:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:101:9 +======= + --> $DIR/rename.rs:84:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::positional_named_format_parameters)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `named_arguments_used_positionally` error: lint `clippy::temporary_cstring_as_ptr` has been renamed to `temporary_cstring_as_ptr` --> $DIR/rename.rs:102:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:102:9 +======= + --> $DIR/rename.rs:85:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `temporary_cstring_as_ptr` @@ -308,15 +728,45 @@ LL | #![warn(clippy::undropped_manually_drops)] error: lint `clippy::unknown_clippy_lints` has been renamed to `unknown_lints` --> $DIR/rename.rs:104:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:104:9 +======= + --> $DIR/rename.rs:86:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::unknown_clippy_lints)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unknown_lints` error: lint `clippy::unused_label` has been renamed to `unused_labels` --> $DIR/rename.rs:105:9 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/rename.rs:105:9 +======= + --> $DIR/rename.rs:87:9 +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | #![warn(clippy::unused_label)] | ^^^^^^^^^^^^^^^^^^^^ help: use the new name: `unused_labels` error: aborting due to 53 previous errors +<<<<<<< HEAD +======= +<<<<<<< HEAD +error: aborting due to 53 previous errors +======= +error: aborting due to 44 previous errors +>>>>>>> 493b2ae8d (Rename integer_arithmetic) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/same_functions_in_if_condition.stderr b/tests/ui/same_functions_in_if_condition.stderr index 199e6769ff76..d4c60bedfbb6 100644 --- a/tests/ui/same_functions_in_if_condition.stderr +++ b/tests/ui/same_functions_in_if_condition.stderr @@ -53,6 +53,16 @@ LL | if obj.method_arg(a) { error: this `if` has the same function call as a previous `if` --> $DIR/same_functions_in_if_condition.rs:60:15 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/same_functions_in_if_condition.rs:60:15 +======= + --> $DIR/same_functions_in_if_condition.rs:58:15 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else if v.pop().is_none() { | ^^^^^^^^^^^^^^^^^ @@ -65,6 +75,16 @@ LL | if v.pop().is_none() { error: this `if` has the same function call as a previous `if` --> $DIR/same_functions_in_if_condition.rs:65:15 +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/same_functions_in_if_condition.rs:65:15 +======= + --> $DIR/same_functions_in_if_condition.rs:63:15 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | } else if v.len() == 42 { | ^^^^^^^^^^^^^ diff --git a/tests/ui/shadow.rs b/tests/ui/shadow.rs index 9be8c5e59d01..dd5c18920959 100644 --- a/tests/ui/shadow.rs +++ b/tests/ui/shadow.rs @@ -1,4 +1,28 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macro_derive.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macro_derive.rs +======= +// aux-build:proc_macro_derive.rs +>>>>>>> cd0009eb3 (Suppress the triggering of some lints in derived structures) +======= +//@aux-build:proc_macro_derive.rs +>>>>>>> def1705a2 (Update to a compiletest-rs version that requires `//@` for commands) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> cb3ecf7b7 (Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macro_derive.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::shadow_same, clippy::shadow_reuse, clippy::shadow_unrelated)] #![allow(clippy::let_unit_value, clippy::needless_if)] diff --git a/tests/ui/single_call_fn.rs b/tests/ui/single_call_fn.rs index 76e175014b87..a5f50374c97d 100644 --- a/tests/ui/single_call_fn.rs +++ b/tests/ui/single_call_fn.rs @@ -1,5 +1,27 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro #![allow(clippy::redundant_closure_call, unused)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +//@aux-build:proc_macros.rs:proc-macro +#![allow(clippy::redundant_closure_call, unused)] +<<<<<<< HEAD +======= +//@aux-build:proc_macros.rs +<<<<<<< HEAD +#![allow(unused)] +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +#![allow(clippy::redundant_closure_call, unused)] +>>>>>>> a8605269b (add test for closures) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::single_call_fn)] #![no_main] @@ -9,6 +31,16 @@ extern crate proc_macros; // Do not lint since it's public pub fn f() {} +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a8605269b (add test for closures) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn i() {} fn j() {} @@ -26,6 +58,17 @@ fn h() { a(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +>>>>>>> a8605269b (add test for closures) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn g() { f(); } @@ -64,6 +107,16 @@ fn e() { b(); b(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[test] fn k() {} @@ -72,3 +125,14 @@ fn k() {} fn l() { k(); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/single_call_fn.stderr b/tests/ui/single_call_fn.stderr index 9ef8c487844f..f094a55d9977 100644 --- a/tests/ui/single_call_fn.stderr +++ b/tests/ui/single_call_fn.stderr @@ -1,5 +1,42 @@ error: this function is only used once +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/single_call_fn.rs:33:1 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/single_call_fn.rs:33:1 +======= + --> $DIR/single_call_fn.rs:26:1 + | +LL | fn a() {} + | ^^^^^^^^^ + | +help: used here + --> $DIR/single_call_fn.rs:29:5 + | +LL | a(); + | ^ + = note: `-D clippy::single-call-fn` implied by `-D warnings` + +error: this function is only used once + --> $DIR/single_call_fn.rs:16:1 +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= + --> $DIR/single_call_fn.rs:33:1 +>>>>>>> a8605269b (add test for closures) +======= + --> $DIR/single_call_fn.rs:34:1 +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +======= + --> $DIR/single_call_fn.rs:33:1 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/single_call_fn.rs:33:1 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / fn c() { LL | | println!("really"); @@ -9,12 +46,84 @@ LL | | } | |_^ | help: used here +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/single_call_fn.rs:40:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/single_call_fn.rs:40:5 +======= + --> $DIR/single_call_fn.rs:41:5 +>>>>>>> 2cd4a9182 (Ignore functions annotated with `#[test]`) +======= + --> $DIR/single_call_fn.rs:40:5 +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/single_call_fn.rs:40:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) + | +LL | c(); + | ^ + = note: `-D clippy::single-call-fn` implied by `-D warnings` + +error: this function is only used once + --> $DIR/single_call_fn.rs:12:1 + | +LL | fn i() {} + | ^^^^^^^^^ + | +help: used here + --> $DIR/single_call_fn.rs:17:13 + | +LL | let a = i; + | ^ + +error: this function is only used once + --> $DIR/single_call_fn.rs:43:1 + | +LL | fn a() {} + | ^^^^^^^^^ + | +help: used here + --> $DIR/single_call_fn.rs:46:5 + | +LL | a(); + | ^ + +error: this function is only used once + --> $DIR/single_call_fn.rs:13:1 + | +LL | fn j() {} + | ^^^^^^^^^ + | +help: used here + --> $DIR/single_call_fn.rs:24:9 + | +LL | j(); + | ^ + +error: aborting due to 4 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/single_call_fn.rs:23:5 +======= --> $DIR/single_call_fn.rs:40:5 +>>>>>>> a8605269b (add test for closures) | LL | c(); | ^ = note: `-D clippy::single-call-fn` implied by `-D warnings` +<<<<<<< HEAD +error: aborting due to 2 previous errors +>>>>>>> 07dbcbda1 (new lint `single_call_fn`) +======= error: this function is only used once --> $DIR/single_call_fn.rs:12:1 | @@ -52,4 +161,8 @@ LL | j(); | ^ error: aborting due to 4 previous errors +>>>>>>> a8605269b (add test for closures) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/single_char_add_str.fixed b/tests/ui/single_char_add_str.fixed index cb301c8bc152..70a3987d43ea 100644 --- a/tests/ui/single_char_add_str.fixed +++ b/tests/ui/single_char_add_str.fixed @@ -1,6 +1,26 @@ //@run-rustfix #![warn(clippy::single_char_add_str)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +======= +#![allow(clippy::needless_raw_string_hashes)] +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +#![allow(clippy::needless_raw_string, clippy::needless_raw_string_hashes)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! get_string { () => { diff --git a/tests/ui/single_char_add_str.rs b/tests/ui/single_char_add_str.rs index 99baf35ac297..eea99bf42512 100644 --- a/tests/ui/single_char_add_str.rs +++ b/tests/ui/single_char_add_str.rs @@ -1,6 +1,26 @@ //@run-rustfix #![warn(clippy::single_char_add_str)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +======= +#![allow(clippy::needless_raw_string_hashes)] +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +#![allow(clippy::needless_raw_string, clippy::needless_raw_string_hashes)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes)] +>>>>>>> 615b25c20 (Rebase attempt number 2) macro_rules! get_string { () => { diff --git a/tests/ui/single_char_pattern.fixed b/tests/ui/single_char_pattern.fixed index 7ae62231acc0..567b7c6fd942 100644 --- a/tests/ui/single_char_pattern.fixed +++ b/tests/ui/single_char_pattern.fixed @@ -1,6 +1,26 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +======= +#![allow(clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +#![allow(clippy::needless_raw_string, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::collections::HashSet; diff --git a/tests/ui/single_char_pattern.rs b/tests/ui/single_char_pattern.rs index 0604624e767b..2b7dc49862ce 100644 --- a/tests/ui/single_char_pattern.rs +++ b/tests/ui/single_char_pattern.rs @@ -1,6 +1,26 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +======= +#![allow(clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 1bf74fc30 (add `needless_raw_string_hashes` lint) +======= +#![allow(clippy::needless_raw_string, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::needless_raw_strings, clippy::needless_raw_string_hashes, unused_must_use)] +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::collections::HashSet; diff --git a/tests/ui/single_match.fixed b/tests/ui/single_match.fixed index e7b1fd6a85f2..803ff1a82dd8 100644 --- a/tests/ui/single_match.fixed +++ b/tests/ui/single_match.fixed @@ -1,11 +1,33 @@ //@run-rustfix #![warn(clippy::single_match)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( unused, clippy::uninlined_format_args, clippy::needless_if, clippy::redundant_pattern_matching )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(unused, clippy::uninlined_format_args, clippy::redundant_pattern_matching)] +>>>>>>> ed935de08 (Run-rustfix) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn dummy() {} fn single_match() { @@ -212,6 +234,16 @@ fn issue_10808(bar: Option) { } } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d7e723441 ([`single_match`]: don't lint if block contains comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod issue8634 { struct SomeError(i32, i32); @@ -237,6 +269,16 @@ mod issue8634 { }, } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2e856fa99 (add test for block comment and add note to description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn block_comment(x: Result) { match x { @@ -252,3 +294,14 @@ mod issue8634 { } } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> ed935de08 (Run-rustfix) +======= +} +>>>>>>> d7e723441 ([`single_match`]: don't lint if block contains comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/single_match.rs b/tests/ui/single_match.rs index 1515a7053e5d..4431aeb71187 100644 --- a/tests/ui/single_match.rs +++ b/tests/ui/single_match.rs @@ -1,11 +1,38 @@ //@run-rustfix #![warn(clippy::single_match)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( unused, clippy::uninlined_format_args, clippy::needless_if, clippy::redundant_pattern_matching )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(unused, clippy::uninlined_format_args)] + +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= +#![allow(unused, clippy::uninlined_format_args, clippy::redundant_pattern_matching)] +>>>>>>> ed935de08 (Run-rustfix) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn dummy() {} fn single_match() { @@ -260,8 +287,28 @@ fn issue_10808(bar: Option) { } match bar { +<<<<<<< HEAD +<<<<<<< HEAD #[rustfmt::skip] Some(v) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + Some(v) => { +======= + Some(v) => { + // this comment prevents rustfmt from collapsing the block +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= + #[rustfmt::skip] + Some(v) => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #[rustfmt::skip] + Some(v) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe { let r = &v as *const i32; println!("{}", *r); @@ -270,6 +317,16 @@ fn issue_10808(bar: Option) { _ => {}, } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> d7e723441 ([`single_match`]: don't lint if block contains comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod issue8634 { struct SomeError(i32, i32); @@ -295,6 +352,16 @@ mod issue8634 { }, } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 2e856fa99 (add test for block comment and add note to description) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn block_comment(x: Result) { match x { @@ -310,3 +377,14 @@ mod issue8634 { } } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= +} +>>>>>>> d7e723441 ([`single_match`]: don't lint if block contains comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/single_match.stderr b/tests/ui/single_match.stderr index 76f7e7895898..f953e156fa0a 100644 --- a/tests/ui/single_match.stderr +++ b/tests/ui/single_match.stderr @@ -156,7 +156,23 @@ LL | | } | |_____^ help: try: `if let (.., Some(E::V), _) = (Some(42), Some(E::V), Some(42)) {}` error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/single_match.rs:254:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/single_match.rs:254:5 +======= + --> $DIR/single_match.rs:249:5 +>>>>>>> e92614818 (Fix unsafe blocks) +======= + --> $DIR/single_match.rs:254:5 +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/single_match.rs:254:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / match bar { LL | | Some(v) => unsafe { @@ -176,11 +192,39 @@ LL + } } | error: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + --> $DIR/single_match.rs:262:5 + | +LL | / match bar { +LL | | #[rustfmt::skip] +LL | | Some(v) => { +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/single_match.rs:257:5 +======= --> $DIR/single_match.rs:262:5 +>>>>>>> 26f50395b (Add `needless_if` lint) | LL | / match bar { LL | | #[rustfmt::skip] LL | | Some(v) => { +<<<<<<< HEAD +LL | | // this comment prevents rustfmt from collapsing the block +>>>>>>> e92614818 (Fix unsafe blocks) +======= +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) LL | | unsafe { ... | LL | | _ => {}, @@ -190,6 +234,19 @@ LL | | } help: try | LL ~ if let Some(v) = bar { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +LL + // this comment prevents rustfmt from collapsing the block +>>>>>>> e92614818 (Fix unsafe blocks) +======= +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) LL + unsafe { LL + let r = &v as *const i32; LL + println!("{}", *r); diff --git a/tests/ui/single_match_else.fixed b/tests/ui/single_match_else.fixed index fcc8f14803d3..aceca252a11e 100644 --- a/tests/ui/single_match_else.fixed +++ b/tests/ui/single_match_else.fixed @@ -1,5 +1,21 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build: proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build: proc_macros.rs:proc-macro +======= +//@aux-build: proc_macros.rs +>>>>>>> ed935de08 (Run-rustfix) +======= +//@aux-build: proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build: proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::single_match_else)] #![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] extern crate proc_macros; diff --git a/tests/ui/single_match_else.rs b/tests/ui/single_match_else.rs index 77afd58a08dc..a5990a054ff8 100644 --- a/tests/ui/single_match_else.rs +++ b/tests/ui/single_match_else.rs @@ -1,7 +1,33 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build: proc_macros.rs:proc-macro #![warn(clippy::single_match_else)] #![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build: proc_macros.rs:proc-macro +#![warn(clippy::single_match_else)] +#![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] +<<<<<<< HEAD +======= + +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= +//@aux-build: proc_macros.rs +======= +//@aux-build: proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +#![warn(clippy::single_match_else)] +#![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] +>>>>>>> ed935de08 (Run-rustfix) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build: proc_macros.rs:proc-macro +#![warn(clippy::single_match_else)] +#![allow(unused, clippy::needless_return, clippy::no_effect, clippy::uninlined_format_args)] +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; use proc_macros::with_span; @@ -153,8 +179,28 @@ fn issue_10808(bar: Option) { } match bar { +<<<<<<< HEAD +<<<<<<< HEAD #[rustfmt::skip] Some(v) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + Some(v) => { +======= + Some(v) => { + // this comment prevents rustfmt from collapsing the block +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= + #[rustfmt::skip] + Some(v) => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #[rustfmt::skip] + Some(v) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe { let r = &v as *const i32; println!("{}", *r); @@ -171,8 +217,28 @@ fn issue_10808(bar: Option) { println!("Some"); println!("{v}"); }, +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + None => { +======= +<<<<<<< HEAD +<<<<<<< HEAD #[rustfmt::skip] None => { +======= + None => { + // this comment prevents rustfmt from collapsing the block +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= + #[rustfmt::skip] + None => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #[rustfmt::skip] + None => { +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe { let v = 0; let r = &v as *const i32; @@ -182,15 +248,55 @@ fn issue_10808(bar: Option) { } match bar { +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + Some(v) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + Some(v) => { +======= + Some(v) => { + // this comment prevents rustfmt from collapsing the block +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= #[rustfmt::skip] Some(v) => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + #[rustfmt::skip] + Some(v) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe { let r = &v as *const i32; println!("{}", *r); } }, +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + None => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + #[rustfmt::skip] + None => { +======= + None => { + // this comment prevents rustfmt from collapsing the block +>>>>>>> 1c277d1be (Unit tests highlighting unsafe match issue) +======= + #[rustfmt::skip] + None => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= #[rustfmt::skip] None => { +>>>>>>> 615b25c20 (Rebase attempt number 2) unsafe { let v = 0; let r = &v as *const i32; diff --git a/tests/ui/single_match_else.stderr b/tests/ui/single_match_else.stderr index 5e7d4062efea..f37b0fc83675 100644 --- a/tests/ui/single_match_else.stderr +++ b/tests/ui/single_match_else.stderr @@ -175,8 +175,28 @@ error: you seem to be trying to use `match` for destructuring a single pattern. --> $DIR/single_match_else.rs:155:5 | LL | / match bar { +<<<<<<< HEAD +<<<<<<< HEAD LL | | #[rustfmt::skip] LL | | Some(v) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD +LL | | #[rustfmt::skip] +LL | | Some(v) => { +======= +LL | | Some(v) => { +LL | | // this comment prevents rustfmt from collapsing the block +>>>>>>> e92614818 (Fix unsafe blocks) +======= +LL | | #[rustfmt::skip] +LL | | Some(v) => { +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +LL | | #[rustfmt::skip] +LL | | Some(v) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) LL | | unsafe { ... | LL | | }, @@ -186,6 +206,19 @@ LL | | } help: try | LL ~ if let Some(v) = bar { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +LL + // this comment prevents rustfmt from collapsing the block +>>>>>>> e92614818 (Fix unsafe blocks) +======= +>>>>>>> 9fd34e0c7 (Use #[rustfmt::skip]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) LL + unsafe { LL + let r = &v as *const i32; LL + println!("{}", *r); diff --git a/tests/ui/single_range_in_vec_init.rs b/tests/ui/single_range_in_vec_init.rs index 833e1c43bfc0..6e98647b7161 100644 --- a/tests/ui/single_range_in_vec_init.rs +++ b/tests/ui/single_range_in_vec_init.rs @@ -1,4 +1,20 @@ +<<<<<<< HEAD +<<<<<<< HEAD //@aux-build:proc_macros.rs:proc-macro +======= +<<<<<<< HEAD +<<<<<<< HEAD +//@aux-build:proc_macros.rs:proc-macro +======= +//@aux-build:proc_macros.rs +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +//@aux-build:proc_macros.rs:proc-macro +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(clippy::no_effect, clippy::useless_vec, unused)] #![warn(clippy::single_range_in_vec_init)] #![feature(generic_arg_infer)] @@ -39,8 +55,28 @@ fn main() { [0.0..200.0]; vec![0.0..200.0]; // `Copy` is not implemented for `Range`, so this doesn't matter +<<<<<<< HEAD +<<<<<<< HEAD + // FIXME: [0..200; 2]; + // FIXME: [vec!0..200; 2]; +======= +<<<<<<< HEAD +<<<<<<< HEAD + // FIXME: [0..200; 2]; + // FIXME: [vec!0..200; 2]; +======= + // [0..200; 2]; + // [vec!0..200; 2]; +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= + // FIXME: [0..200; 2]; + // FIXME: [vec!0..200; 2]; +>>>>>>> 5bd97ac17 (Update tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // FIXME: [0..200; 2]; // FIXME: [vec!0..200; 2]; +>>>>>>> 615b25c20 (Rebase attempt number 2) // Unfortunately skips any macros a!(); diff --git a/tests/ui/single_range_in_vec_init.stderr b/tests/ui/single_range_in_vec_init.stderr index 3e3d521f4a50..8d022a19b20d 100644 --- a/tests/ui/single_range_in_vec_init.stderr +++ b/tests/ui/single_range_in_vec_init.stderr @@ -5,7 +5,23 @@ LL | [0..200]; | ^^^^^^^^ | = note: `-D clippy::single-range-in-vec-init` implied by `-D warnings` +<<<<<<< HEAD +<<<<<<< HEAD help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -20,7 +36,23 @@ error: a `Vec` of `Range` that is only one element LL | vec![0..200]; | ^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -35,7 +67,23 @@ error: an array of `Range` that is only one element LL | [0u8..200]; | ^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0u8..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -50,7 +98,23 @@ error: an array of `Range` that is only one element LL | [0usize..200]; | ^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0usize..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -65,7 +129,23 @@ error: an array of `Range` that is only one element LL | [0..200usize]; | ^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200usize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -80,7 +160,23 @@ error: a `Vec` of `Range` that is only one element LL | vec![0u8..200]; | ^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0u8..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -95,7 +191,23 @@ error: a `Vec` of `Range` that is only one element LL | vec![0usize..200]; | ^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0usize..200).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -110,7 +222,23 @@ error: a `Vec` of `Range` that is only one element LL | vec![0..200usize]; | ^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200usize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -125,7 +253,23 @@ error: an array of `Range` that is only one element LL | [0..200isize]; | ^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200isize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -136,7 +280,23 @@ error: a `Vec` of `Range` that is only one element LL | vec![0..200isize]; | ^^^^^^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +<<<<<<< HEAD +<<<<<<< HEAD +help: if you wanted a `Vec` that contains the entire range, try +======= +help: if you wanted a `Vec` that contains every value in the range, try +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +======= +help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 830d307d0 (refactor a bit) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= help: if you wanted a `Vec` that contains the entire range, try +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | (0..200isize).collect::>(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/ui/suspicious_else_formatting.rs b/tests/ui/suspicious_else_formatting.rs index 0473ccdc3f63..b2a15d70993d 100644 --- a/tests/ui/suspicious_else_formatting.rs +++ b/tests/ui/suspicious_else_formatting.rs @@ -1,12 +1,34 @@ //@aux-build:proc_macro_suspicious_else_formatting.rs:proc-macro #![warn(clippy::suspicious_else_formatting)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::if_same_then_else, clippy::let_unit_value, clippy::needless_if, clippy::needless_else )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +#![allow(clippy::if_same_then_else, clippy::let_unit_value, clippy::needless_else)] +>>>>>>> e6646eb5f (needless_else: new lint to check for empty else clauses) +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macro_suspicious_else_formatting; use proc_macro_suspicious_else_formatting::DeriveBadSpan; diff --git a/tests/ui/tuple_array_conversions.rs b/tests/ui/tuple_array_conversions.rs index f96a7c97f1aa..f372dee47829 100644 --- a/tests/ui/tuple_array_conversions.rs +++ b/tests/ui/tuple_array_conversions.rs @@ -1,5 +1,21 @@ //@aux-build:proc_macros.rs:proc-macro +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::no_effect, clippy::useless_vec, unused)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::no_effect, clippy::useless_vec, unused)] +======= +#![allow(clippy::useless_vec, unused)] +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= +#![allow(clippy::no_effect, clippy::useless_vec, unused)] +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::no_effect, clippy::useless_vec, unused)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::tuple_array_conversions)] #[macro_use] @@ -21,9 +37,31 @@ fn main() { let v2: Vec<[u32; 2]> = t1.iter().map(|&t| t.into()).collect(); let t3: Vec<(u32, u32)> = v2.iter().map(|&v| v.into()).collect(); let x = [1; 13]; +<<<<<<< HEAD +<<<<<<< HEAD + let x = ( + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], + ); +======= +<<<<<<< HEAD +<<<<<<< HEAD + let x = ( + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], + ); +======= + let x = (x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12]); +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + let x = ( + x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], + ); +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let x = ( x[0], x[1], x[2], x[3], x[4], x[5], x[6], x[7], x[8], x[9], x[10], x[11], x[12], ); +>>>>>>> 615b25c20 (Rebase attempt number 2) let x = [x.0, x.1, x.2, x.3, x.4, x.5, x.6, x.7, x.8, x.9, x.10, x.11, x.12]; let x = (1, 2); let x = (x.0, x.1); @@ -31,6 +69,16 @@ fn main() { let x = [x[0], x[1]]; let x = vec![1, 2]; let x = (x[0], x[1]); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let x = [1; 3]; let x = (x[0],); let x = (1, 2, 3); @@ -39,8 +87,32 @@ fn main() { let y = (1, 2); [x.0, y.0]; [x.0, y.1]; +<<<<<<< HEAD +<<<<<<< HEAD + let x = [x.0, x.0]; + let x = (x[0], x[0]); +======= +<<<<<<< HEAD +<<<<<<< HEAD + let x = [x.0, x.0]; + let x = (x[0], x[0]); +======= +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + // FP + let x = [x.0, x.0]; + let x = (x[0], x[0]); + // How can this be fixed? +>>>>>>> b1acbde61 (Add msrv check and make test pass) +======= + let x = [x.0, x.0]; + let x = (x[0], x[0]); +>>>>>>> 95b24d44a (Fix FP) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let x = [x.0, x.0]; let x = (x[0], x[0]); +>>>>>>> 615b25c20 (Rebase attempt number 2) external! { let t1: &[(u32, u32)] = &[(1, 2), (3, 4)]; let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); @@ -53,6 +125,16 @@ fn main() { let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[clippy::msrv = "1.70.0"] fn msrv_too_low() { @@ -71,3 +153,14 @@ fn msrv_juust_right() { let x = &[1, 2]; let x = (x[0], x[1]); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/tuple_array_conversions.stderr b/tests/ui/tuple_array_conversions.stderr index be653e8efb79..5427254158aa 100644 --- a/tests/ui/tuple_array_conversions.stderr +++ b/tests/ui/tuple_array_conversions.stderr @@ -4,7 +4,23 @@ error: it looks like you're trying to convert an array to a tuple LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) = note: `-D clippy::tuple-array-conversions` implied by `-D warnings` error: it looks like you're trying to convert a tuple to an array @@ -13,7 +29,23 @@ error: it looks like you're trying to convert a tuple to an array LL | let x = [x.0, x.1]; | ^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it looks like you're trying to convert an array to a tuple --> $DIR/tuple_array_conversions.rs:13:13 @@ -21,7 +53,23 @@ error: it looks like you're trying to convert an array to a tuple LL | let x = (x[0], x[1]); | ^^^^^^^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it looks like you're trying to convert a tuple to an array --> $DIR/tuple_array_conversions.rs:16:53 @@ -29,7 +77,23 @@ error: it looks like you're trying to convert a tuple to an array LL | let v1: Vec<[u32; 2]> = t1.iter().map(|&(a, b)| [a, b]).collect(); | ^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it looks like you're trying to convert a tuple to an array --> $DIR/tuple_array_conversions.rs:17:38 @@ -37,7 +101,23 @@ error: it looks like you're trying to convert a tuple to an array LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it looks like you're trying to convert an array to a tuple --> $DIR/tuple_array_conversions.rs:18:55 @@ -45,7 +125,23 @@ error: it looks like you're trying to convert an array to a tuple LL | let t2: Vec<(u32, u32)> = v1.iter().map(|&[a, b]| (a, b)).collect(); | ^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= +<<<<<<< HEAD +<<<<<<< HEAD + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +======= + = help: use `.into()` instead +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> b1acbde61 (Add msrv check and make test pass) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +>>>>>>> 615b25c20 (Rebase attempt number 2) error: it looks like you're trying to convert a tuple to an array --> $DIR/tuple_array_conversions.rs:19:38 @@ -53,6 +149,50 @@ error: it looks like you're trying to convert a tuple to an array LL | t1.iter().for_each(|&(a, b)| _ = [a, b]); | ^^^^^^ | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed + +error: it looks like you're trying to convert an array to a tuple + --> $DIR/tuple_array_conversions.rs:69:13 + | +LL | let x = (x[0], x[1]); + | ^^^^^^^^^^^^ + | + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed + +error: it looks like you're trying to convert a tuple to an array + --> $DIR/tuple_array_conversions.rs:70:13 + | +LL | let x = [x.0, x.1]; + | ^^^^^^^^^^ + | + = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed + +error: it looks like you're trying to convert an array to a tuple + --> $DIR/tuple_array_conversions.rs:72:13 + | +LL | let x = (x[0], x[1]); + | ^^^^^^^^^^^^ + | + = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed + +error: aborting due to 10 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + = help: use `.into()` instead + +error: aborting due to 7 previous errors +>>>>>>> bfcc8ba44 (New lint `tuple_array_conversions`) +======= = help: use `.into()` instead, or `<[T; N]>::from` if type annotations are needed error: it looks like you're trying to convert an array to a tuple @@ -79,5 +219,13 @@ LL | let x = (x[0], x[1]); | = help: use `.into()` instead, or `<(T0, T1, ..., Tn)>::from` if type annotations are needed +<<<<<<< HEAD +error: aborting due to 12 previous errors +>>>>>>> b1acbde61 (Add msrv check and make test pass) +======= error: aborting due to 10 previous errors +>>>>>>> 95b24d44a (Fix FP) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/undocumented_unsafe_blocks.rs b/tests/ui/undocumented_unsafe_blocks.rs index a9cc42954356..5b88d158fb9d 100644 --- a/tests/ui/undocumented_unsafe_blocks.rs +++ b/tests/ui/undocumented_unsafe_blocks.rs @@ -513,14 +513,45 @@ pub unsafe fn a_function_with_a_very_long_name_to_break_the_line() -> u32 { 1 } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) pub const unsafe fn a_const_function_with_a_very_long_name_to_break_the_line() -> u32 { 2 } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn issue_10832() { // Safety: A safety comment. But it will warn anyways let _some_variable_with_a_very_long_name_to_break_the_line = unsafe { a_function_with_a_very_long_name_to_break_the_line() }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Safety: Another safety comment. But it will warn anyways const _SOME_CONST_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 = @@ -529,6 +560,17 @@ fn issue_10832() { // Safety: Yet another safety comment. But it will warn anyways static _SOME_STATIC_WITH_A_VERY_LONG_NAME_TO_BREAK_THE_LINE: u32 = unsafe { a_const_function_with_a_very_long_name_to_break_the_line() }; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn main() {} diff --git a/tests/ui/undocumented_unsafe_blocks.stderr b/tests/ui/undocumented_unsafe_blocks.stderr index ee1d3aa285a2..4d8acda26fe2 100644 --- a/tests/ui/undocumented_unsafe_blocks.stderr +++ b/tests/ui/undocumented_unsafe_blocks.stderr @@ -319,13 +319,39 @@ LL | let bar = unsafe {}; = help: consider adding a safety comment on the preceding line error: unsafe block missing a safety comment +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/undocumented_unsafe_blocks.rs:523:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/undocumented_unsafe_blocks.rs:523:9 +======= + --> $DIR/undocumented_unsafe_blocks.rs:519:9 +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= + --> $DIR/undocumented_unsafe_blocks.rs:523:9 +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/undocumented_unsafe_blocks.rs:523:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | unsafe { a_function_with_a_very_long_name_to_break_the_line() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider adding a safety comment on the preceding line +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: unsafe block missing a safety comment --> $DIR/undocumented_unsafe_blocks.rs:527:9 | @@ -343,4 +369,16 @@ LL | unsafe { a_const_function_with_a_very_long_name_to_break_the_line() = help: consider adding a safety comment on the preceding line error: aborting due to 39 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +error: aborting due to 37 previous errors +>>>>>>> 520228b37 (Adding configuration to allow safety comment above stmt containing unsafe block) +======= +>>>>>>> e2e6a0244 (Addressing reviewer comments) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/unnecessary_cast.fixed b/tests/ui/unnecessary_cast.fixed index 8efd44baf59f..428d8ff00af6 100644 --- a/tests/ui/unnecessary_cast.fixed +++ b/tests/ui/unnecessary_cast.fixed @@ -2,6 +2,19 @@ //@aux-build:extern_fake_libc.rs #![warn(clippy::unnecessary_cast)] #![allow( +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + unused, +>>>>>>> d2de5769a (add generics in test) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::borrow_as_ptr, clippy::no_effect, clippy::nonstandard_macro_braces, @@ -10,6 +23,16 @@ unused )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate extern_fake_libc; type PtrConstU8 = *const u8; @@ -23,6 +46,16 @@ fn uwu(ptr: *const T) -> *const U { ptr as *const U } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod fake_libc { type pid_t = i32; pub unsafe fn getpid() -> pid_t { @@ -38,6 +71,22 @@ mod fake_libc { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +type PtrConstU8 = *const u8; +type PtrMutU8 = *mut u8; + +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +>>>>>>> d2de5769a (add generics in test) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[rustfmt::skip] fn main() { // Test cast_unnecessary @@ -52,8 +101,26 @@ fn main() { 1_i32; 1_f32; +<<<<<<< HEAD +<<<<<<< HEAD + let _: *mut u8 = [1u8, 2].as_ptr() as *mut u8; + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _: *mut u8 = [1u8, 2].as_ptr() as *mut u8; + +======= +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= let _: *mut u8 = [1u8, 2].as_ptr() as *mut u8; +>>>>>>> d2de5769a (add generics in test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let _: *mut u8 = [1u8, 2].as_ptr() as *mut u8; + +>>>>>>> 615b25c20 (Rebase attempt number 2) [1u8, 2].as_ptr(); [1u8, 2].as_ptr() as *mut u8; [1u8, 2].as_mut_ptr(); @@ -64,6 +131,14 @@ fn main() { [1u8, 2].as_mut_ptr() as PtrConstU8; let _: *const u8 = [1u8, 2].as_ptr() as _; let _: *mut u8 = [1u8, 2].as_mut_ptr() as _; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _: *const u8 = [1u8, 2].as_ptr() as *const _; let _: *mut u8 = [1u8, 2].as_mut_ptr() as *mut _; @@ -71,6 +146,23 @@ fn main() { uwu::([1u32].as_ptr()); // this will not lint in the function body even though they have the same type, instead here uwu::([1u32].as_ptr()); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + let _: *const u8 = [1u8, 2].as_ptr() as *const _; + let _: *mut u8 = [1u8, 2].as_mut_ptr() as *mut _; +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) + + owo::([1u32].as_ptr()); + uwu::([1u32].as_ptr()); + // this will not lint in the function body even though they have the same type, instead here + uwu::([1u32].as_ptr()); +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // macro version macro_rules! foo { @@ -101,10 +193,42 @@ fn main() { // or from let x: I32Alias = 1; let y = x as u64; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fake_libc::getpid_SAFE_TRUTH(&0u32) as i32; extern_fake_libc::getpid_SAFE_TRUTH() as i32; let pid = unsafe { fake_libc::getpid() }; pid as i32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + + let i8_ptr: *const i8 = &1; + let u8_ptr: *const u8 = &1; + + // cfg dependant pointees + i8_ptr as *const std::os::raw::c_char; + u8_ptr as *const std::os::raw::c_char; + + // type aliased pointees + i8_ptr as *const std::ffi::c_char; + u8_ptr as *const std::ffi::c_char; +======= +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let i8_ptr: *const i8 = &1; let u8_ptr: *const u8 = &1; diff --git a/tests/ui/unnecessary_cast.rs b/tests/ui/unnecessary_cast.rs index c7723ef51f99..9cb38f388cfc 100644 --- a/tests/ui/unnecessary_cast.rs +++ b/tests/ui/unnecessary_cast.rs @@ -2,6 +2,19 @@ //@aux-build:extern_fake_libc.rs #![warn(clippy::unnecessary_cast)] #![allow( +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + unused, +>>>>>>> d2de5769a (add generics in test) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::borrow_as_ptr, clippy::no_effect, clippy::nonstandard_macro_braces, @@ -10,6 +23,16 @@ unused )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate extern_fake_libc; type PtrConstU8 = *const u8; @@ -23,6 +46,16 @@ fn uwu(ptr: *const T) -> *const U { ptr as *const U } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod fake_libc { type pid_t = i32; pub unsafe fn getpid() -> pid_t { @@ -38,6 +71,22 @@ mod fake_libc { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +type PtrConstU8 = *const u8; +type PtrMutU8 = *mut u8; + +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +>>>>>>> d2de5769a (add generics in test) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[rustfmt::skip] fn main() { // Test cast_unnecessary @@ -52,8 +101,26 @@ fn main() { 1_i32 as i32; 1_f32 as f32; +<<<<<<< HEAD +<<<<<<< HEAD + let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; + +======= +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; +>>>>>>> d2de5769a (add generics in test) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; + +>>>>>>> 615b25c20 (Rebase attempt number 2) [1u8, 2].as_ptr() as *const u8; [1u8, 2].as_ptr() as *mut u8; [1u8, 2].as_mut_ptr() as *mut u8; @@ -64,6 +131,14 @@ fn main() { [1u8, 2].as_mut_ptr() as PtrConstU8; let _: *const u8 = [1u8, 2].as_ptr() as _; let _: *mut u8 = [1u8, 2].as_mut_ptr() as _; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let _: *const u8 = [1u8, 2].as_ptr() as *const _; let _: *mut u8 = [1u8, 2].as_mut_ptr() as *mut _; @@ -71,6 +146,23 @@ fn main() { uwu::([1u32].as_ptr()) as *const u8; // this will not lint in the function body even though they have the same type, instead here uwu::([1u32].as_ptr()) as *const u32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + let _: *const u8 = [1u8, 2].as_ptr() as *const _; + let _: *mut u8 = [1u8, 2].as_mut_ptr() as *mut _; +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) + + owo::([1u32].as_ptr()) as *const u32; + uwu::([1u32].as_ptr()) as *const u8; + // this will not lint in the function body even though they have the same type, instead here + uwu::([1u32].as_ptr()) as *const u32; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // macro version macro_rules! foo { @@ -101,10 +193,42 @@ fn main() { // or from let x: I32Alias = 1; let y = x as u64; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fake_libc::getpid_SAFE_TRUTH(&0u32) as i32; extern_fake_libc::getpid_SAFE_TRUTH() as i32; let pid = unsafe { fake_libc::getpid() }; pid as i32; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + + let i8_ptr: *const i8 = &1; + let u8_ptr: *const u8 = &1; + + // cfg dependant pointees + i8_ptr as *const std::os::raw::c_char; + u8_ptr as *const std::os::raw::c_char; + + // type aliased pointees + i8_ptr as *const std::ffi::c_char; + u8_ptr as *const std::ffi::c_char; +======= +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let i8_ptr: *const i8 = &1; let u8_ptr: *const u8 = &1; diff --git a/tests/ui/unnecessary_cast.stderr b/tests/ui/unnecessary_cast.stderr index f0443556fb4d..80191d31bced 100644 --- a/tests/ui/unnecessary_cast.stderr +++ b/tests/ui/unnecessary_cast.stderr @@ -1,5 +1,29 @@ +<<<<<<< HEAD +<<<<<<< HEAD error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) --> $DIR/unnecessary_cast.rs:19:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) + --> $DIR/unnecessary_cast.rs:19:5 +======= +error: casting integer literal to `i32` is unnecessary + --> $DIR/unnecessary_cast.rs:17:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:15:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:19:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: casting raw pointers to the same type and constness is unnecessary (`*const T` -> `*const T`) + --> $DIR/unnecessary_cast.rs:19:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | ptr as *const T | ^^^^^^^^^^^^^^^ help: try: `ptr` @@ -7,226 +31,1353 @@ LL | ptr as *const T = note: `-D clippy::unnecessary-cast` implied by `-D warnings` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:44:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:44:5 +======= + --> $DIR/unnecessary_cast.rs:25:5 +>>>>>>> d2de5769a (add generics in test) +======= --> $DIR/unnecessary_cast.rs:44:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:44:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1i32 as i32; | ^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:45:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:45:5 +======= + --> $DIR/unnecessary_cast.rs:18:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:26:5 +>>>>>>> d2de5769a (add generics in test) +======= --> $DIR/unnecessary_cast.rs:45:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:45:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1f32 as f32; | ^^^^^^^^^^^ help: try: `1_f32` error: casting to the same type is unnecessary (`bool` -> `bool`) +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:46:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:46:5 +======= + --> $DIR/unnecessary_cast.rs:19:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:27:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:46:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:46:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | false as bool; | ^^^^^^^^^^^^^ help: try: `false` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:49:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:49:5 +======= + --> $DIR/unnecessary_cast.rs:22:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:30:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:49:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:49:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | -1_i32 as i32; | ^^^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:50:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:50:5 +======= + --> $DIR/unnecessary_cast.rs:23:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:31:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:50:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:50:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | - 1_i32 as i32; | ^^^^^^^^^^^^^^ help: try: `- 1_i32` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:51:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:51:5 +======= + --> $DIR/unnecessary_cast.rs:24:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:32:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:51:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:51:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | -1f32 as f32; | ^^^^^^^^^^^^ help: try: `-1_f32` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:52:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:52:5 +======= + --> $DIR/unnecessary_cast.rs:25:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:33:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:52:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:52:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1_i32 as i32; | ^^^^^^^^^^^^ help: try: `1_i32` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:53:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:53:5 +======= + --> $DIR/unnecessary_cast.rs:26:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:34:5 +>>>>>>> d2de5769a (add generics in test) +======= --> $DIR/unnecessary_cast.rs:53:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:53:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1_f32 as f32; | ^^^^^^^^^^^^ help: try: `1_f32` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:55:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:55:22 +======= + --> $DIR/unnecessary_cast.rs:36:22 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:55:22 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:55:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: *mut u8 = [1u8, 2].as_ptr() as *const u8 as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:57:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:57:5 +======= + --> $DIR/unnecessary_cast.rs:28:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:38:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:57:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:57:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | [1u8, 2].as_ptr() as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_ptr()` error: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:59:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:59:5 +======= + --> $DIR/unnecessary_cast.rs:30:5 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:40:5 +>>>>>>> d2de5769a (add generics in test) +======= --> $DIR/unnecessary_cast.rs:59:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:59:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | [1u8, 2].as_mut_ptr() as *mut u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[1u8, 2].as_mut_ptr()` +<<<<<<< HEAD +<<<<<<< HEAD +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) + --> $DIR/unnecessary_cast.rs:70:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) + --> $DIR/unnecessary_cast.rs:70:5 +<<<<<<< HEAD +======= +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:49:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:51:5 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) --> $DIR/unnecessary_cast.rs:70:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | owo::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `owo::([1u32].as_ptr())` error: casting raw pointers to the same type and constness is unnecessary (`*const u8` -> `*const u8`) +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:71:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:71:5 +======= + --> $DIR/unnecessary_cast.rs:50:5 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:52:5 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:71:5 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:71:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | uwu::([1u32].as_ptr()) as *const u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` +<<<<<<< HEAD +<<<<<<< HEAD error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) --> $DIR/unnecessary_cast.rs:73:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) + --> $DIR/unnecessary_cast.rs:73:5 +<<<<<<< HEAD +======= +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:52:5 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:54:5 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +error: casting raw pointers to the same type and constness is unnecessary (`*const u32` -> `*const u32`) + --> $DIR/unnecessary_cast.rs:73:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | uwu::([1u32].as_ptr()) as *const u32; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `uwu::([1u32].as_ptr())` error: casting integer literal to `f32` is unnecessary +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:139:9 +======= +<<<<<<< HEAD +error: casting integer literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:139:9 +======= +error: casting integer literal to `f32` is unnecessary + --> $DIR/unnecessary_cast.rs:78:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +error: casting integer literal to `f32` is unnecessary + --> $DIR/unnecessary_cast.rs:91:9 +>>>>>>> d2de5769a (add generics in test) +======= +error: casting integer literal to `f32` is unnecessary +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:93:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:106:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:117:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:116:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:139:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:139:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 100 as f32; | ^^^^^^^^^^ help: try: `100_f32` error: casting integer literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:140:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:140:9 +======= + --> $DIR/unnecessary_cast.rs:79:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:92:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:94:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:107:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:118:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:117:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:140:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:140:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 100 as f64; | ^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:141:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:141:9 +======= + --> $DIR/unnecessary_cast.rs:80:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:93:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:95:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:108:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:119:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:118:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:141:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:141:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 100_i32 as f64; | ^^^^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:142:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:142:17 +======= + --> $DIR/unnecessary_cast.rs:81:17 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:94:17 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:96:17 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:109:17 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:120:17 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:119:17 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:142:17 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:142:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = -100 as f32; | ^^^^^^^^^^^ help: try: `-100_f32` error: casting integer literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:143:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:143:17 +======= + --> $DIR/unnecessary_cast.rs:82:17 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:95:17 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:97:17 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:110:17 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:121:17 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:120:17 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:143:17 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:143:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = -100 as f64; | ^^^^^^^^^^^ help: try: `-100_f64` error: casting integer literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:144:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:144:17 +======= + --> $DIR/unnecessary_cast.rs:83:17 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:96:17 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:98:17 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:111:17 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:122:17 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:121:17 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:144:17 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:144:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = -100_i32 as f64; | ^^^^^^^^^^^^^^^ help: try: `-100_f64` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:145:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:145:9 +======= + --> $DIR/unnecessary_cast.rs:84:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:97:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:99:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:112:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:123:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:122:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:145:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:145:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 100. as f32; | ^^^^^^^^^^^ help: try: `100_f32` error: casting float literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:146:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:146:9 +======= + --> $DIR/unnecessary_cast.rs:85:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:98:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:100:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:113:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:124:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:123:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:146:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:146:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 100. as f64; | ^^^^^^^^^^^ help: try: `100_f64` error: casting integer literal to `u32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:158:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:158:9 +======= + --> $DIR/unnecessary_cast.rs:97:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:110:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:112:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:125:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:136:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:135:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:158:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:158:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1 as u32; | ^^^^^^^^ help: try: `1_u32` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:159:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:159:9 +======= + --> $DIR/unnecessary_cast.rs:98:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:111:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:113:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:126:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:137:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:136:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:159:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:159:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 0x10 as i32; | ^^^^^^^^^^^ help: try: `0x10_i32` error: casting integer literal to `usize` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:160:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:160:9 +======= + --> $DIR/unnecessary_cast.rs:99:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:112:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:114:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:127:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:138:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:137:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:160:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:160:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 0b10 as usize; | ^^^^^^^^^^^^^ help: try: `0b10_usize` error: casting integer literal to `u16` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:161:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:161:9 +======= + --> $DIR/unnecessary_cast.rs:100:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:113:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:115:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:128:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:139:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:138:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:161:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:161:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 0o73 as u16; | ^^^^^^^^^^^ help: try: `0o73_u16` error: casting integer literal to `u32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:162:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:162:9 +======= + --> $DIR/unnecessary_cast.rs:101:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:114:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:116:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:129:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:140:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:139:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:162:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:162:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1_000_000_000 as u32; | ^^^^^^^^^^^^^^^^^^^^ help: try: `1_000_000_000_u32` error: casting float literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:164:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:164:9 +======= + --> $DIR/unnecessary_cast.rs:103:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:116:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:118:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:131:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:142:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:141:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:164:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:164:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 1.0 as f64; | ^^^^^^^^^^ help: try: `1.0_f64` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:165:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:165:9 +======= + --> $DIR/unnecessary_cast.rs:104:9 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:117:9 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:119:9 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:132:9 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:143:9 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:142:9 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:165:9 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:165:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | 0.5 as f32; | ^^^^^^^^^^ help: try: `0.5_f32` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:169:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:169:17 +======= + --> $DIR/unnecessary_cast.rs:108:17 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:121:17 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:123:17 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:136:17 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:147:17 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:146:17 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= --> $DIR/unnecessary_cast.rs:169:17 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:169:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = -1 as i32; | ^^^^^^^^^ help: try: `-1_i32` error: casting float literal to `f32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:170:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:170:17 +======= + --> $DIR/unnecessary_cast.rs:109:17 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:122:17 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:124:17 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:137:17 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:148:17 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:147:17 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:170:17 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:170:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = -1.0 as f32; | ^^^^^^^^^^^ help: try: `-1.0_f32` error: casting to the same type is unnecessary (`i32` -> `i32`) +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:176:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:176:18 +======= + --> $DIR/unnecessary_cast.rs:115:18 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:128:18 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:130:18 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:143:18 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:154:18 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:153:18 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:176:18 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:176:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = &(x as i32); | ^^^^^^^^^^ help: try: `{ x }` error: casting integer literal to `i32` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:182:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:182:22 +======= + --> $DIR/unnecessary_cast.rs:121:22 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:134:22 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:136:22 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:149:22 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:160:22 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:159:22 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:182:22 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:182:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: i32 = -(1) as i32; | ^^^^^^^^^^^ help: try: `-1_i32` error: casting integer literal to `i64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:184:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:184:22 +======= + --> $DIR/unnecessary_cast.rs:123:22 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:136:22 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:138:22 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:151:22 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:162:22 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:161:22 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:184:22 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_cast.rs:184:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: i64 = -(1) as i64; | ^^^^^^^^^^^ help: try: `-1_i64` error: casting float literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:191:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:191:22 +======= + --> $DIR/unnecessary_cast.rs:130:22 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:143:22 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:145:22 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:158:22 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:169:22 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:168:22 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:191:22 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:191:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: f64 = (-8.0 as f64).exp(); | ^^^^^^^^^^^^^ help: try: `(-8.0_f64)` error: casting float literal to `f64` is unnecessary +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:193:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_cast.rs:193:23 +======= + --> $DIR/unnecessary_cast.rs:132:23 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:145:23 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:147:23 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:160:23 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:171:23 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:170:23 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= + --> $DIR/unnecessary_cast.rs:193:23 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:193:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: f64 = -(8.0 as f64).exp(); // should suggest `-8.0_f64.exp()` here not to change code behavior | ^^^^^^^^^^^^ help: try: `8.0_f64` error: casting to the same type is unnecessary (`f32` -> `f32`) +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:201:20 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_cast.rs:201:20 +======= + --> $DIR/unnecessary_cast.rs:140:20 +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= + --> $DIR/unnecessary_cast.rs:153:20 +>>>>>>> d2de5769a (add generics in test) +======= + --> $DIR/unnecessary_cast.rs:155:20 +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +======= + --> $DIR/unnecessary_cast.rs:168:20 +>>>>>>> 4346c992c (Ignore more pointer types in `unnecessary_cast`) +======= + --> $DIR/unnecessary_cast.rs:179:20 +>>>>>>> 4c7bc1785 (ignore more type aliases in unnecessary_cast) +======= + --> $DIR/unnecessary_cast.rs:178:20 +>>>>>>> 382244133 (Update unnecessary_cast.stderr) +======= --> $DIR/unnecessary_cast.rs:201:20 +>>>>>>> 357e80ea0 (Ignore more type aliases in `unnecessary_cast`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_cast.rs:201:20 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _num = foo() as f32; | ^^^^^^^^^^^^ help: try: `foo()` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 38 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 38 previous errors +======= +error: aborting due to 33 previous errors +>>>>>>> 7f7979f80 (emit `unnecessary_cast` on raw pointers as well) +======= +error: aborting due to 37 previous errors +>>>>>>> d2de5769a (add generics in test) +======= +error: aborting due to 38 previous errors +>>>>>>> d7a98f507 (also ensure generics with the same type are linted) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 38 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/unnecessary_lazy_eval.fixed b/tests/ui/unnecessary_lazy_eval.fixed index dca38034177b..d552908b25d0 100644 --- a/tests/ui/unnecessary_lazy_eval.fixed +++ b/tests/ui/unnecessary_lazy_eval.fixed @@ -5,9 +5,30 @@ #![allow(clippy::bind_instead_of_map)] #![allow(clippy::map_identity)] #![allow(clippy::needless_borrow)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::unnecessary_literal_unwrap)] use std::ops::Deref; +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::unnecessary_literal_unwrap)] + +use std::ops::Deref; +======= +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= +#![allow(clippy::unnecessary_literal_unwrap)] +>>>>>>> bfd5abad4 (Fix all the other tests) + +use std::ops::Deref; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::unnecessary_literal_unwrap)] + +use std::ops::Deref; +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; use proc_macros::with_span; @@ -83,9 +104,30 @@ fn main() { let _ = Some(1).unwrap_or(*r); let b = Box::new(1); let _ = Some(1).unwrap_or(*b); +<<<<<<< HEAD +<<<<<<< HEAD // Should lint - Builtin deref through autoderef let _ = Some(1).as_ref().unwrap_or(&r); let _ = Some(1).as_ref().unwrap_or(&b); +======= +<<<<<<< HEAD +<<<<<<< HEAD + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or(&r); + let _ = Some(1).as_ref().unwrap_or(&b); +======= +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or(&r); + let _ = Some(1).as_ref().unwrap_or(&b); +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or(&r); + let _ = Some(1).as_ref().unwrap_or(&b); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Cases when unwrap is not called on a simple variable let _ = Some(10).unwrap_or(2); @@ -118,9 +160,30 @@ fn main() { let _ = Some(1).unwrap_or_else(|| *Issue10437); // Issue10437 has a deref impl let _ = Some(1).unwrap_or(*Issue10437); +<<<<<<< HEAD +<<<<<<< HEAD + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +======= +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); let _ = Some(1).as_ref().unwrap_or(&Issue10437); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Should not lint - bool let _ = (0 == 1).then(|| Issue9427(0)); // Issue9427 has a significant drop let _ = false.then(|| Issue9427FollowUp); // Issue9427FollowUp has a significant drop diff --git a/tests/ui/unnecessary_lazy_eval.rs b/tests/ui/unnecessary_lazy_eval.rs index 7fda719edc1b..affabaf65708 100644 --- a/tests/ui/unnecessary_lazy_eval.rs +++ b/tests/ui/unnecessary_lazy_eval.rs @@ -5,9 +5,30 @@ #![allow(clippy::bind_instead_of_map)] #![allow(clippy::map_identity)] #![allow(clippy::needless_borrow)] +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::unnecessary_literal_unwrap)] use std::ops::Deref; +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::unnecessary_literal_unwrap)] + +use std::ops::Deref; +======= +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= +#![allow(clippy::unnecessary_literal_unwrap)] +>>>>>>> bfd5abad4 (Fix all the other tests) + +use std::ops::Deref; +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::unnecessary_literal_unwrap)] + +use std::ops::Deref; +>>>>>>> 615b25c20 (Rebase attempt number 2) extern crate proc_macros; use proc_macros::with_span; @@ -83,9 +104,30 @@ fn main() { let _ = Some(1).unwrap_or_else(|| *r); let b = Box::new(1); let _ = Some(1).unwrap_or_else(|| *b); +<<<<<<< HEAD +<<<<<<< HEAD // Should lint - Builtin deref through autoderef let _ = Some(1).as_ref().unwrap_or_else(|| &r); let _ = Some(1).as_ref().unwrap_or_else(|| &b); +======= +<<<<<<< HEAD +<<<<<<< HEAD + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or_else(|| &r); + let _ = Some(1).as_ref().unwrap_or_else(|| &b); +======= +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or_else(|| &r); + let _ = Some(1).as_ref().unwrap_or_else(|| &b); +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // Should lint - Builtin deref through autoderef + let _ = Some(1).as_ref().unwrap_or_else(|| &r); + let _ = Some(1).as_ref().unwrap_or_else(|| &b); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Cases when unwrap is not called on a simple variable let _ = Some(10).unwrap_or_else(|| 2); @@ -118,9 +160,30 @@ fn main() { let _ = Some(1).unwrap_or_else(|| *Issue10437); // Issue10437 has a deref impl let _ = Some(1).unwrap_or(*Issue10437); +<<<<<<< HEAD +<<<<<<< HEAD + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +======= +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); + let _ = Some(1).as_ref().unwrap_or(&Issue10437); + +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= let _ = Some(1).as_ref().unwrap_or_else(|| &Issue10437); let _ = Some(1).as_ref().unwrap_or(&Issue10437); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Should not lint - bool let _ = (0 == 1).then(|| Issue9427(0)); // Issue9427 has a significant drop let _ = false.then(|| Issue9427FollowUp); // Issue9427FollowUp has a significant drop diff --git a/tests/ui/unnecessary_lazy_eval.stderr b/tests/ui/unnecessary_lazy_eval.stderr index 458eed1f359a..65503c579ca3 100644 --- a/tests/ui/unnecessary_lazy_eval.stderr +++ b/tests/ui/unnecessary_lazy_eval.stderr @@ -1,5 +1,25 @@ error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:69:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:69:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:67:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:68:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:69:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:69:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.unwrap_or_else(|| 2); | ^^^^-------------------- @@ -9,7 +29,27 @@ LL | let _ = opt.unwrap_or_else(|| 2); = note: `-D clippy::unnecessary-lazy-evaluations` implied by `-D warnings` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:70:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:70:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:68:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:69:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:70:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:70:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | ^^^^--------------------------------- @@ -17,7 +57,27 @@ LL | let _ = opt.unwrap_or_else(|| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:71:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:71:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:69:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:70:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:71:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:71:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | ^^^^------------------------------------- @@ -25,7 +85,27 @@ LL | let _ = opt.unwrap_or_else(|| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:73:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:73:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:71:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:72:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:73:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:73:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.and_then(|_| ext_opt); | ^^^^--------------------- @@ -33,7 +113,27 @@ LL | let _ = opt.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:74:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:74:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:72:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:73:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:74:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:74:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.or_else(|| ext_opt); | ^^^^------------------- @@ -41,7 +141,27 @@ LL | let _ = opt.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:75:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:75:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:73:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:74:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:75:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:75:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.or_else(|| None); | ^^^^---------------- @@ -49,7 +169,27 @@ LL | let _ = opt.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:76:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:76:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:74:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:75:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:76:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:76:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.get_or_insert_with(|| 2); | ^^^^------------------------ @@ -57,7 +197,27 @@ LL | let _ = opt.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:77:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:77:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:75:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:76:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:77:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:77:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.ok_or_else(|| 2); | ^^^^---------------- @@ -65,7 +225,27 @@ LL | let _ = opt.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:78:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:78:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:76:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:77:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:78:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:78:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | ^^^^^^^^^^^^^^^^^------------------------------- @@ -73,7 +253,27 @@ LL | let _ = nested_tuple_opt.unwrap_or_else(|| Some((1, 2))); | help: use `unwrap_or(..)` instead: `unwrap_or(Some((1, 2)))` error: unnecessary closure used with `bool::then` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:79:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:79:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:77:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:78:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:79:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:79:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = cond.then(|| astronomers_pi); | ^^^^^----------------------- @@ -81,7 +281,27 @@ LL | let _ = cond.then(|| astronomers_pi); | help: use `then_some(..)` instead: `then_some(astronomers_pi)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:83:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:83:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:81:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:82:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:83:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:83:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(1).unwrap_or_else(|| *r); | ^^^^^^^^--------------------- @@ -89,7 +309,27 @@ LL | let _ = Some(1).unwrap_or_else(|| *r); | help: use `unwrap_or(..)` instead: `unwrap_or(*r)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:85:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:85:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:83:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:84:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:85:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:85:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(1).unwrap_or_else(|| *b); | ^^^^^^^^--------------------- @@ -97,6 +337,14 @@ LL | let _ = Some(1).unwrap_or_else(|| *b); | help: use `unwrap_or(..)` instead: `unwrap_or(*b)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/unnecessary_lazy_eval.rs:87:13 | LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); @@ -114,6 +362,34 @@ LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); error: unnecessary closure used to substitute value for `Option::None` --> $DIR/unnecessary_lazy_eval.rs:91:13 +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + --> $DIR/unnecessary_lazy_eval.rs:86:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:87:13 +>>>>>>> bfd5abad4 (Fix all the other tests) + | +LL | let _ = Some(1).as_ref().unwrap_or_else(|| &r); + | ^^^^^^^^^^^^^^^^^--------------------- + | | + | help: use `unwrap_or(..)` instead: `unwrap_or(&r)` + +error: unnecessary closure used to substitute value for `Option::None` + --> $DIR/unnecessary_lazy_eval.rs:88:13 + | +LL | let _ = Some(1).as_ref().unwrap_or_else(|| &b); + | ^^^^^^^^^^^^^^^^^--------------------- + | | + | help: use `unwrap_or(..)` instead: `unwrap_or(&b)` + +error: unnecessary closure used to substitute value for `Option::None` + --> $DIR/unnecessary_lazy_eval.rs:91:13 +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(10).unwrap_or_else(|| 2); | ^^^^^^^^^-------------------- @@ -121,7 +397,27 @@ LL | let _ = Some(10).unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:92:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:92:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:87:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:91:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:92:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:92:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = Some(10).and_then(|_| ext_opt); | ^^^^^^^^^--------------------- @@ -129,7 +425,27 @@ LL | let _ = Some(10).and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:93:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:93:28 +======= + --> $DIR/unnecessary_lazy_eval.rs:88:28 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:92:28 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:93:28 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:93:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Option = None.or_else(|| ext_opt); | ^^^^^------------------- @@ -137,7 +453,27 @@ LL | let _: Option = None.or_else(|| ext_opt); | help: use `or(..)` instead: `or(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:94:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:94:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:89:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:93:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:94:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:94:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = None.get_or_insert_with(|| 2); | ^^^^^------------------------ @@ -145,7 +481,27 @@ LL | let _ = None.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:95:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:95:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:90:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:94:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:95:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:95:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = None.ok_or_else(|| 2); | ^^^^^---------------- @@ -153,7 +509,27 @@ LL | let _: Result = None.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:96:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:96:28 +======= + --> $DIR/unnecessary_lazy_eval.rs:91:28 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:95:28 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:96:28 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:96:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Option = None.or_else(|| None); | ^^^^^---------------- @@ -161,7 +537,27 @@ LL | let _: Option = None.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:99:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:99:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:94:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:98:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:99:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:99:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.unwrap_or_else(|| 2); | ^^^^^^^-------------------- @@ -169,7 +565,27 @@ LL | let _ = deep.0.unwrap_or_else(|| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:100:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:100:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:95:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:99:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:100:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:100:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.and_then(|_| ext_opt); | ^^^^^^^--------------------- @@ -177,7 +593,27 @@ LL | let _ = deep.0.and_then(|_| ext_opt); | help: use `and(..)` instead: `and(ext_opt)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:101:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:101:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:96:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:100:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:101:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:101:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.or_else(|| None); | ^^^^^^^---------------- @@ -185,7 +621,27 @@ LL | let _ = deep.0.or_else(|| None); | help: use `or(..)` instead: `or(None)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:102:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:102:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:97:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:101:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:102:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:102:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.get_or_insert_with(|| 2); | ^^^^^^^------------------------ @@ -193,7 +649,27 @@ LL | let _ = deep.0.get_or_insert_with(|| 2); | help: use `get_or_insert(..)` instead: `get_or_insert(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:103:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:103:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:98:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:102:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:103:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:103:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.ok_or_else(|| 2); | ^^^^^^^---------------- @@ -201,7 +677,27 @@ LL | let _ = deep.0.ok_or_else(|| 2); | help: use `ok_or(..)` instead: `ok_or(2)` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:133:28 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:133:28 +======= + --> $DIR/unnecessary_lazy_eval.rs:125:28 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:132:28 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:133:28 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:133:28 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Option = None.or_else(|| Some(3)); | ^^^^^------------------- @@ -209,7 +705,27 @@ LL | let _: Option = None.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:134:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:134:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:126:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:133:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:134:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:134:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = deep.0.or_else(|| Some(3)); | ^^^^^^^------------------- @@ -217,7 +733,27 @@ LL | let _ = deep.0.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Option::None` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:135:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:135:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:127:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:134:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:135:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:135:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = opt.or_else(|| Some(3)); | ^^^^------------------- @@ -225,7 +761,27 @@ LL | let _ = opt.or_else(|| Some(3)); | help: use `or(..)` instead: `or(Some(3))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:141:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:141:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:133:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:140:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:141:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:141:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = res2.unwrap_or_else(|_| 2); | ^^^^^--------------------- @@ -233,7 +789,27 @@ LL | let _ = res2.unwrap_or_else(|_| 2); | help: use `unwrap_or(..)` instead: `unwrap_or(2)` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:142:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:142:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:134:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:141:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:142:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:142:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | ^^^^^---------------------------------- @@ -241,7 +817,27 @@ LL | let _ = res2.unwrap_or_else(|_| astronomers_pi); | help: use `unwrap_or(..)` instead: `unwrap_or(astronomers_pi)` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:143:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:143:13 +======= + --> $DIR/unnecessary_lazy_eval.rs:135:13 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:142:13 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:143:13 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:143:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | ^^^^^-------------------------------------- @@ -249,7 +845,27 @@ LL | let _ = res2.unwrap_or_else(|_| ext_str.some_field); | help: use `unwrap_or(..)` instead: `unwrap_or(ext_str.some_field)` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:165:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:165:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:157:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:164:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:165:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:165:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.and_then(|_| Err(2)); | ^^^^-------------------- @@ -257,7 +873,27 @@ LL | let _: Result = res.and_then(|_| Err(2)); | help: use `and(..)` instead: `and(Err(2))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:166:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:166:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:158:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:165:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:166:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnecessary_lazy_eval.rs:166:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | ^^^^--------------------------------- @@ -265,7 +901,27 @@ LL | let _: Result = res.and_then(|_| Err(astronomers_pi)); | help: use `and(..)` instead: `and(Err(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:167:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:167:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:159:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:166:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:167:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:167:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)); | ^^^^------------------------------------- @@ -273,7 +929,27 @@ LL | let _: Result = res.and_then(|_| Err(ext_str.some_field)) | help: use `and(..)` instead: `and(Err(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:169:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:169:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:161:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:168:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:169:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:169:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.or_else(|_| Ok(2)); | ^^^^------------------ @@ -281,7 +957,27 @@ LL | let _: Result = res.or_else(|_| Ok(2)); | help: use `or(..)` instead: `or(Ok(2))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:170:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:170:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:162:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:169:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:170:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:170:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | ^^^^------------------------------- @@ -289,7 +985,27 @@ LL | let _: Result = res.or_else(|_| Ok(astronomers_pi)); | help: use `or(..)` instead: `or(Ok(astronomers_pi))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_lazy_eval.rs:171:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:171:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:163:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:170:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= + --> $DIR/unnecessary_lazy_eval.rs:171:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:171:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | ^^^^----------------------------------- @@ -297,7 +1013,27 @@ LL | let _: Result = res.or_else(|_| Ok(ext_str.some_field)); | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` error: unnecessary closure used to substitute value for `Result::Err` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:172:35 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_lazy_eval.rs:172:35 +======= + --> $DIR/unnecessary_lazy_eval.rs:164:35 +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= + --> $DIR/unnecessary_lazy_eval.rs:171:35 +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +======= --> $DIR/unnecessary_lazy_eval.rs:172:35 +>>>>>>> bfd5abad4 (Fix all the other tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_lazy_eval.rs:172:35 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _: Result = res. | ___________________________________^ @@ -311,5 +1047,21 @@ LL | | or_else(|_| Ok(ext_str.some_field)); | | | help: use `or(..)` instead: `or(Ok(ext_str.some_field))` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 38 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 38 previous errors +======= +error: aborting due to 36 previous errors +>>>>>>> a239c8b52 ([`unnecessary_lazy_eval`]: don't lint on types with deref impl) +======= +error: aborting due to 38 previous errors +>>>>>>> e70dd55fd (account for autoderef in eager_or_lazy) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 38 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/unnecessary_literal_unwrap.fixed b/tests/ui/unnecessary_literal_unwrap.fixed index 276cd800b890..2eba54ff04b1 100644 --- a/tests/ui/unnecessary_literal_unwrap.fixed +++ b/tests/ui/unnecessary_literal_unwrap.fixed @@ -1,3 +1,11 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@run-rustfix #![warn(clippy::unnecessary_literal_unwrap)] #![allow(unreachable_code)] @@ -7,6 +15,13 @@ clippy::let_unit_value, clippy::no_effect )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn unwrap_option_some() { let _val = 1; @@ -95,5 +110,109 @@ fn main() { unwrap_result_err(); unwrap_methods_option(); unwrap_methods_result(); +<<<<<<< HEAD +<<<<<<< HEAD unwrap_unchecked(); +======= +<<<<<<< HEAD +======= +//run-rustfix +======= +//@run-rustfix +>>>>>>> 6cf138e9b (Add more tests) +#![warn(clippy::unnecessary_literal_unwrap)] +#![allow(unreachable_code)] +#![allow(clippy::unnecessary_lazy_evaluations)] +======= +>>>>>>> 6e4c5561b (Preserve type annotations when present) + +fn unwrap_option_some() { + let _val = 1; + let _val = 1; + + 1; + 1; +} + +fn unwrap_option_none() { + let _val = panic!(); + let _val = panic!("this always happens"); + + panic!(); + panic!("this always happens"); +} + +fn unwrap_result_ok() { + let _val = 1; + let _val = 1; + let _val = panic!("{:?}", 1); + let _val = panic!("{1}: {:?}", 1, "this always happens"); + + 1; + 1; + panic!("{:?}", 1); + panic!("{1}: {:?}", 1, "this always happens"); +} + +fn unwrap_result_err() { + let _val = 1; + let _val = 1; + let _val = panic!("{:?}", 1); + let _val = panic!("{1}: {:?}", 1, "this always happens"); + + 1; + 1; + panic!("{:?}", 1); + panic!("{1}: {:?}", 1, "this always happens"); +} + +fn unwrap_methods_option() { + let _val = 1; + let _val = 1; + let _val = 1; + + 1; + 1; + 1; +} + +fn unwrap_methods_result() { + let _val = 1; + let _val = 1; + let _val = 1; + + 1; + 1; + 1; +} + +fn main() { +<<<<<<< HEAD + unwrap_option(); +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> daf619748 (Implement the suggestion) +======= + unwrap_result(); +<<<<<<< HEAD +>>>>>>> 1d159e7d1 (Recognize `Ok`) +======= +======= +======= + unwrap_option_some(); + unwrap_option_none(); +>>>>>>> 6e4dc93e2 (Support suggesting panics) + unwrap_result_ok(); + unwrap_result_err(); +>>>>>>> 69af0e13b (Recognize `Err`) + unwrap_methods_option(); + unwrap_methods_result(); +>>>>>>> 8f8350298 (Recognize `unwrap_or` methods) +======= + unwrap_unchecked(); +>>>>>>> cd1c8532e ([`unnecessary_literal_unwrap`]: lint `unwrap_unchecked`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + unwrap_unchecked(); +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/unnecessary_literal_unwrap.rs b/tests/ui/unnecessary_literal_unwrap.rs index 3065778d7790..54a0a6c7f4b0 100644 --- a/tests/ui/unnecessary_literal_unwrap.rs +++ b/tests/ui/unnecessary_literal_unwrap.rs @@ -1,3 +1,12 @@ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) //@run-rustfix #![warn(clippy::unnecessary_literal_unwrap)] #![allow(unreachable_code)] @@ -7,6 +16,13 @@ clippy::let_unit_value, clippy::no_effect )] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn unwrap_option_some() { let _val = Some(1).unwrap(); @@ -95,5 +111,111 @@ fn main() { unwrap_result_err(); unwrap_methods_option(); unwrap_methods_result(); +<<<<<<< HEAD +<<<<<<< HEAD unwrap_unchecked(); +======= +<<<<<<< HEAD +======= +======= +//run-rustfix +>>>>>>> daf619748 (Implement the suggestion) +======= +//@run-rustfix +>>>>>>> 6cf138e9b (Add more tests) +#![warn(clippy::unnecessary_literal_unwrap)] +#![allow(unreachable_code)] +#![allow(clippy::unnecessary_lazy_evaluations)] +======= +>>>>>>> 6e4c5561b (Preserve type annotations when present) + +fn unwrap_option_some() { + let _val = Some(1).unwrap(); + let _val = Some(1).expect("this never happens"); + + Some(1).unwrap(); + Some(1).expect("this never happens"); +} + +fn unwrap_option_none() { + let _val = None::<()>.unwrap(); + let _val = None::<()>.expect("this always happens"); + + None::<()>.unwrap(); + None::<()>.expect("this always happens"); +} + +fn unwrap_result_ok() { + let _val = Ok::<_, ()>(1).unwrap(); + let _val = Ok::<_, ()>(1).expect("this never happens"); + let _val = Ok::<_, ()>(1).unwrap_err(); + let _val = Ok::<_, ()>(1).expect_err("this always happens"); + + Ok::<_, ()>(1).unwrap(); + Ok::<_, ()>(1).expect("this never happens"); + Ok::<_, ()>(1).unwrap_err(); + Ok::<_, ()>(1).expect_err("this always happens"); +} + +fn unwrap_result_err() { + let _val = Err::<(), _>(1).unwrap_err(); + let _val = Err::<(), _>(1).expect_err("this never happens"); + let _val = Err::<(), _>(1).unwrap(); + let _val = Err::<(), _>(1).expect("this always happens"); + + Err::<(), _>(1).unwrap_err(); + Err::<(), _>(1).expect_err("this never happens"); + Err::<(), _>(1).unwrap(); + Err::<(), _>(1).expect("this always happens"); +} + +fn unwrap_methods_option() { + let _val = Some(1).unwrap_or(2); + let _val = Some(1).unwrap_or_default(); + let _val = Some(1).unwrap_or_else(|| 2); + + Some(1).unwrap_or(2); + Some(1).unwrap_or_default(); + Some(1).unwrap_or_else(|| 2); +} + +fn unwrap_methods_result() { + let _val = Ok::<_, ()>(1).unwrap_or(2); + let _val = Ok::<_, ()>(1).unwrap_or_default(); + let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2); + + Ok::<_, ()>(1).unwrap_or(2); + Ok::<_, ()>(1).unwrap_or_default(); + Ok::<_, ()>(1).unwrap_or_else(|_| 2); +} + +fn main() { +<<<<<<< HEAD + unwrap_option(); +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> e707447a8 (Boilerplate for the new lint) +======= + unwrap_result(); +<<<<<<< HEAD +>>>>>>> 1d159e7d1 (Recognize `Ok`) +======= +======= +======= + unwrap_option_some(); + unwrap_option_none(); +>>>>>>> 6e4dc93e2 (Support suggesting panics) + unwrap_result_ok(); + unwrap_result_err(); +>>>>>>> 69af0e13b (Recognize `Err`) + unwrap_methods_option(); + unwrap_methods_result(); +>>>>>>> 8f8350298 (Recognize `unwrap_or` methods) +======= + unwrap_unchecked(); +>>>>>>> cd1c8532e ([`unnecessary_literal_unwrap`]: lint `unwrap_unchecked`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + unwrap_unchecked(); +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/unnecessary_literal_unwrap.stderr b/tests/ui/unnecessary_literal_unwrap.stderr index 5823313b736c..d02d07b4e4fa 100644 --- a/tests/ui/unnecessary_literal_unwrap.stderr +++ b/tests/ui/unnecessary_literal_unwrap.stderr @@ -1,5 +1,28 @@ error: used `unwrap()` on `Some` value +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_literal_unwrap.rs:12:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_literal_unwrap.rs:12:16 +======= + --> $DIR/unnecessary_literal_unwrap.rs:6:16 +>>>>>>> 7ed7283e0 (Recognize `unwrap_or_else` method) +======= + --> $DIR/unnecessary_literal_unwrap.rs:7:16 +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= + --> $DIR/unnecessary_literal_unwrap.rs:12:16 +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_literal_unwrap.rs:12:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _val = Some(1).unwrap(); | ^^^^^^^^^^^^^^^^ @@ -12,7 +35,24 @@ LL + let _val = 1; | error: used `expect()` on `Some` value +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_literal_unwrap.rs:13:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_literal_unwrap.rs:13:16 +======= + --> $DIR/unnecessary_literal_unwrap.rs:8:16 +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= + --> $DIR/unnecessary_literal_unwrap.rs:13:16 +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_literal_unwrap.rs:13:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _val = Some(1).expect("this never happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,6 +63,14 @@ LL - let _val = Some(1).expect("this never happens"); LL + let _val = 1; | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap()` on `Some` value --> $DIR/unnecessary_literal_unwrap.rs:15:5 | @@ -75,12 +123,88 @@ error: used `expect()` on `None` value | LL | None::<()>.expect("this always happens"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: used `unwrap()` on `None` value + --> $DIR/unnecessary_literal_unwrap.rs:12:5 +======= +error: used `unwrap()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:15:5 +>>>>>>> 6e4c5561b (Preserve type annotations when present) + | +LL | Some(1).unwrap(); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap()` + | +LL - Some(1).unwrap(); +LL + 1; + | + +error: used `expect()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:16:5 + | +LL | Some(1).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `expect()` + | +LL - Some(1).expect("this never happens"); +LL + 1; + | + +error: used `unwrap()` on `None` value + --> $DIR/unnecessary_literal_unwrap.rs:20:16 + | +LL | let _val = None::<()>.unwrap(); + | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` + +error: used `expect()` on `None` value + --> $DIR/unnecessary_literal_unwrap.rs:21:16 + | +<<<<<<< HEAD +LL | None::.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= +LL | let _val = None::<()>.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `None` and `expect()` + | +LL | let _val = panic!("this always happens"); + | ~~~~~~~ ~ + +error: used `unwrap()` on `None` value + --> $DIR/unnecessary_literal_unwrap.rs:23:5 + | +LL | None::<()>.unwrap(); + | ^^^^^^^^^^^^^^^^^^^ help: remove the `None` and `unwrap()`: `panic!()` + +error: used `expect()` on `None` value + --> $DIR/unnecessary_literal_unwrap.rs:24:5 + | +LL | None::<()>.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | help: remove the `None` and `expect()` | LL | panic!("this always happens"); | ~~~~~~~ ~ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap()` on `Ok` value --> $DIR/unnecessary_literal_unwrap.rs:28:16 | @@ -409,6 +533,424 @@ LL - Ok::<_, ()>(1).unwrap_or_else(|_| 2); LL + 1; | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +error: aborting due to 36 previous errors +======= + --> $DIR/unnecessary_literal_unwrap.rs:4:15 +======= + --> $DIR/unnecessary_literal_unwrap.rs:5:15 +>>>>>>> daf619748 (Implement the suggestion) +======= + --> $DIR/unnecessary_literal_unwrap.rs:5:16 +>>>>>>> 1d159e7d1 (Recognize `Ok`) + | +LL | let _val = Some(1).unwrap(); + | ^^^^^^^^^^^^^^^^ + | + = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings` +help: remove the `Some` and `unwrap()` + | +LL - let _val = Some(1).unwrap(); +LL + let _val = 1; + | + +<<<<<<< HEAD +error: aborting due to previous error +>>>>>>> 0b1bb5fbf (Implement the lint) +======= +error: used `expect()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:6:16 +======= + --> $DIR/unnecessary_literal_unwrap.rs:7:16 +>>>>>>> 7ed7283e0 (Recognize `unwrap_or_else` method) + | +LL | let _val = Some(1).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `expect()` + | +LL - let _val = Some(1).expect("this never happens"); +LL + let _val = 1; + | + +<<<<<<< HEAD +error: aborting due to 2 previous errors +>>>>>>> 21b88ce29 (Implement the lint for expect) +======= +======= +>>>>>>> 6e4dc93e2 (Support suggesting panics) +error: used `unwrap()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:28:16 + | +LL | let _val = Ok::<_, ()>(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap()` + | +LL - let _val = Ok::<_, ()>(1).unwrap(); +LL + let _val = 1; + | + +error: used `expect()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:29:16 + | +LL | let _val = Ok::<_, ()>(1).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect()` + | +LL - let _val = Ok::<_, ()>(1).expect("this never happens"); +LL + let _val = 1; + | + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 4 previous errors +>>>>>>> 1d159e7d1 (Recognize `Ok`) +======= +error: used `unwrap_or()` on `Some` value +======= +======= +error: used `unwrap_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:30:16 + | +LL | let _val = Ok::<_, ()>(1).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_err()` + | +LL | let _val = panic!("{:?}", 1); + | ~~~~~~~~~~~~~~ ~ + +error: used `expect_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:31:16 + | +LL | let _val = Ok::<_, ()>(1).expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect_err()` + | +LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); + | ~~~~~~~~~~~~~~~~~~~ ~ + +error: used `unwrap()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:33:5 + | +LL | Ok::<_, ()>(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap()` + | +LL - Ok::<_, ()>(1).unwrap(); +LL + 1; + | + +error: used `expect()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:34:5 + | +LL | Ok::<_, ()>(1).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect()` + | +LL - Ok::<_, ()>(1).expect("this never happens"); +LL + 1; + | + +error: used `unwrap_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:35:5 + | +LL | Ok::<_, ()>(1).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_err()` + | +LL | panic!("{:?}", 1); + | ~~~~~~~~~~~~~~ ~ + +error: used `expect_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:36:5 + | +LL | Ok::<_, ()>(1).expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect_err()` + | +LL | panic!("{1}: {:?}", 1, "this always happens"); + | ~~~~~~~~~~~~~~~~~~~ ~ + +>>>>>>> 6e4dc93e2 (Support suggesting panics) +error: used `unwrap_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:40:16 + | +LL | let _val = Err::<(), _>(1).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap_err()` + | +LL - let _val = Err::<(), _>(1).unwrap_err(); +LL + let _val = 1; + | + +error: used `expect_err()` on `Err` value +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 69af0e13b (Recognize `Err`) + --> $DIR/unnecessary_literal_unwrap.rs:17:16 +======= + --> $DIR/unnecessary_literal_unwrap.rs:25:16 +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= + --> $DIR/unnecessary_literal_unwrap.rs:41:16 +>>>>>>> 6e4c5561b (Preserve type annotations when present) + | +LL | let _val = Err::<(), _>(1).expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect_err()` + | +LL - let _val = Err::<(), _>(1).expect_err("this never happens"); +LL + let _val = 1; + | + +error: used `unwrap()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:42:16 + | +LL | let _val = Err::<(), _>(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap()` + | +LL | let _val = panic!("{:?}", 1); + | ~~~~~~~~~~~~~~ ~ + +error: used `expect()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:43:16 + | +LL | let _val = Err::<(), _>(1).expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect()` + | +LL | let _val = panic!("{1}: {:?}", 1, "this always happens"); + | ~~~~~~~~~~~~~~~~~~~ ~ + +error: used `unwrap_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:45:5 + | +LL | Err::<(), _>(1).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap_err()` + | +LL - Err::<(), _>(1).unwrap_err(); +LL + 1; + | + +error: used `expect_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:46:5 + | +LL | Err::<(), _>(1).expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect_err()` + | +LL - Err::<(), _>(1).expect_err("this never happens"); +LL + 1; + | + +error: used `unwrap()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:47:5 + | +LL | Err::<(), _>(1).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap()` + | +LL | panic!("{:?}", 1); + | ~~~~~~~~~~~~~~ ~ + +error: used `expect()` on `Err` value + --> $DIR/unnecessary_literal_unwrap.rs:48:5 + | +LL | Err::<(), _>(1).expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect()` + | +LL | panic!("{1}: {:?}", 1, "this always happens"); + | ~~~~~~~~~~~~~~~~~~~ ~ + +error: used `unwrap_or()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:52:16 + | +LL | let _val = Some(1).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or()` + | +LL - let _val = Some(1).unwrap_or(2); +LL + let _val = 1; + | + +error: used `unwrap_or_default()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:53:16 + | +LL | let _val = Some(1).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_default()` + | +LL - let _val = Some(1).unwrap_or_default(); +LL + let _val = 1; + | + +error: used `unwrap_or_else()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:54:16 + | +LL | let _val = Some(1).unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_else()` + | +LL - let _val = Some(1).unwrap_or_else(|| 2); +LL + let _val = 1; + | + +error: used `unwrap_or()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:56:5 + | +LL | Some(1).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or()` + | +LL - Some(1).unwrap_or(2); +LL + 1; + | + +error: used `unwrap_or_default()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:57:5 + | +LL | Some(1).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_default()` + | +LL - Some(1).unwrap_or_default(); +LL + 1; + | + +error: used `unwrap_or_else()` on `Some` value + --> $DIR/unnecessary_literal_unwrap.rs:58:5 + | +LL | Some(1).unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_else()` + | +LL - Some(1).unwrap_or_else(|| 2); +LL + 1; + | + +error: used `unwrap_or()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:62:16 + | +LL | let _val = Ok::<_, ()>(1).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or()` + | +LL - let _val = Ok::<_, ()>(1).unwrap_or(2); +LL + let _val = 1; + | + +error: used `unwrap_or_default()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:63:16 + | +LL | let _val = Ok::<_, ()>(1).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_default()` + | +LL - let _val = Ok::<_, ()>(1).unwrap_or_default(); +LL + let _val = 1; + | + +<<<<<<< HEAD +error: aborting due to 8 previous errors +>>>>>>> 8f8350298 (Recognize `unwrap_or` methods) +======= +error: used `unwrap_or_else()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:64:16 + | +LL | let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_else()` + | +LL - let _val = Ok::<_, ()>(1).unwrap_or_else(|_| 2); +LL + let _val = 1; + | + +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 10 previous errors +>>>>>>> 7ed7283e0 (Recognize `unwrap_or_else` method) +======= +error: aborting due to 12 previous errors +>>>>>>> 69af0e13b (Recognize `Err`) +======= +error: aborting due to 18 previous errors +>>>>>>> 6e4dc93e2 (Support suggesting panics) +======= +error: used `unwrap_or()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:66:5 + | +LL | Ok::<_, ()>(1).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or()` + | +LL - Ok::<_, ()>(1).unwrap_or(2); +LL + 1; + | + +error: used `unwrap_or_default()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:67:5 + | +LL | Ok::<_, ()>(1).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_default()` + | +LL - Ok::<_, ()>(1).unwrap_or_default(); +LL + 1; + | + +error: used `unwrap_or_else()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap.rs:68:5 + | +LL | Ok::<_, ()>(1).unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_else()` + | +LL - Ok::<_, ()>(1).unwrap_or_else(|_| 2); +LL + 1; + | + +error: aborting due to 36 previous errors +>>>>>>> 6e4c5561b (Preserve type annotations when present) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap_unchecked()` on `Some` value --> $DIR/unnecessary_literal_unwrap.rs:82:22 | @@ -481,6 +1023,16 @@ LL - let _ = unsafe { Ok::<_, ()>(1).unwrap_unchecked() } + 1; LL + let _ = 1 + 1; | +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +error: aborting due to 42 previous errors +>>>>>>> cd1c8532e ([`unnecessary_literal_unwrap`]: lint `unwrap_unchecked`) +======= +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap_err_unchecked()` on `Err` value --> $DIR/unnecessary_literal_unwrap.rs:88:22 | @@ -494,4 +1046,11 @@ LL + let _ = 123; | error: aborting due to 43 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 0b5dac097 ([`unnecessary_literal_unwrap`]: also handle unwrap_err_unchecked) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.rs b/tests/ui/unnecessary_literal_unwrap_unfixable.rs index 711fdce39624..bdcae87f51c0 100644 --- a/tests/ui/unnecessary_literal_unwrap_unfixable.rs +++ b/tests/ui/unnecessary_literal_unwrap_unfixable.rs @@ -1,4 +1,15 @@ #![warn(clippy::unnecessary_literal_unwrap)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unreachable_code)] #![allow(clippy::unnecessary_lazy_evaluations, clippy::let_unit_value)] @@ -17,6 +28,13 @@ fn unwrap_option_some_context() { let _val2 = val.expect("this never happens"); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) fn unwrap_option_none() { let val = None::<()>; let _val2 = val.unwrap(); @@ -113,4 +131,127 @@ fn main() { unwrap_methods_option_context(); unwrap_methods_result(); unwrap_methods_result_context(); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +======= +#![allow(clippy::unnecessary_lazy_evaluations)] +#![allow(unreachable_code)] +>>>>>>> 6cf138e9b (Add more tests) + +fn unwrap_option_some() { + let val = Some(1); + let _val2 = val.unwrap(); +<<<<<<< HEAD +>>>>>>> 6e0e09c8f (Track init and unwrap of expr) +======= + let _val2 = val.expect("this never happens"); +} + +======= +>>>>>>> 6e4c5561b (Preserve type annotations when present) +fn unwrap_option_none() { + let val = None::<()>; + let _val2 = val.unwrap(); + let _val2 = val.expect("this always happens"); +} + +fn unwrap_result_ok() { + let val = Ok::<_, ()>(1); + let _val2 = val.unwrap(); + let _val2 = val.expect("this never happens"); + let _val2 = val.unwrap_err(); + let _val2 = val.expect_err("this always happens"); +} + +fn unwrap_result_ok_context() { + let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); + let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); + let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); + let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); + + let val = Ok::([1, 2, 3].iter().sum()); + let _val2 = val.unwrap(); + let _val2 = val.expect("this never happens"); + let _val2 = val.unwrap_err(); + let _val2 = val.expect_err("this always happens"); +} + +fn unwrap_result_err() { + let val = Err::<(), _>(1); + let _val2 = val.unwrap_err(); + let _val2 = val.expect_err("this never happens"); + let _val2 = val.unwrap(); + let _val2 = val.expect("this always happens"); +} + +fn unwrap_result_err_context() { + let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); + let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); + let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); + let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); + + let val = Err::<(), usize>([1, 2, 3].iter().sum()); + let _val2 = val.unwrap_err(); + let _val2 = val.expect_err("this never happens"); + let _val2 = val.unwrap(); + let _val2 = val.expect("this always happens"); +} + +fn unwrap_methods_option() { + let val = Some(1); + let _val2 = val.unwrap_or(2); + let _val2 = val.unwrap_or_default(); + let _val2 = val.unwrap_or_else(|| 2); +} + +fn unwrap_methods_option_context() { + let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); + let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); + let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); + + let val = Some::([1, 2, 3].iter().sum()); + let _val2 = val.unwrap_or(2); + let _val2 = val.unwrap_or_default(); + let _val2 = val.unwrap_or_else(|| 2); +} + +fn unwrap_methods_result() { + let val = Ok::<_, ()>(1); + let _val2 = val.unwrap_or(2); + let _val2 = val.unwrap_or_default(); + let _val2 = val.unwrap_or_else(|_| 2); +} + +fn unwrap_methods_result_context() { + let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); + let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); + let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); + + let val = Ok::([1, 2, 3].iter().sum()); + let _val2 = val.unwrap_or(2); + let _val2 = val.unwrap_or_default(); + let _val2 = val.unwrap_or_else(|_| 2); +} + +fn main() { + unwrap_option_some(); + unwrap_option_some_context(); + unwrap_option_none(); + unwrap_result_ok(); + unwrap_result_ok_context(); + unwrap_result_err(); + unwrap_result_err_context(); + unwrap_methods_option(); + unwrap_methods_option_context(); + unwrap_methods_result(); +<<<<<<< HEAD +>>>>>>> 6cf138e9b (Add more tests) +======= + unwrap_methods_result_context(); +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } diff --git a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr index feb9325b77a6..c0ff6aabd299 100644 --- a/tests/ui/unnecessary_literal_unwrap_unfixable.stderr +++ b/tests/ui/unnecessary_literal_unwrap_unfixable.stderr @@ -1,16 +1,58 @@ error: used `unwrap()` on `Some` value +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:5:17 +>>>>>>> 6e0e09c8f (Track init and unwrap of expr) +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 +>>>>>>> 6cf138e9b (Add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:7:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let _val2 = val.unwrap(); | ^^^^^^^^^^^^ | help: remove the `Some` and `unwrap()` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:4:15 +>>>>>>> 6e0e09c8f (Track init and unwrap of expr) +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 +>>>>>>> 6cf138e9b (Add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:6:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let val = Some(1); | ^^^^^^^ = note: `-D clippy::unnecessary-literal-unwrap` implied by `-D warnings` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 6cf138e9b (Add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `expect()` on `Some` value --> $DIR/unnecessary_literal_unwrap_unfixable.rs:8:17 | @@ -23,6 +65,14 @@ help: remove the `Some` and `expect()` LL | let val = Some(1); | ^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) error: used `unwrap()` on `Some` value --> $DIR/unnecessary_literal_unwrap_unfixable.rs:12:16 | @@ -518,15 +568,622 @@ LL | let val = Ok::<_, ()>(1); error: used `unwrap_or_else()` on `Ok` value --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:17 | -LL | let _val2 = val.unwrap_or_else(|_| 2); - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: used `unwrap()` on `None` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:13:5 +======= +error: used `unwrap()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:12:16 +>>>>>>> 6e4c5561b (Preserve type annotations when present) | -help: remove the `Ok` and `unwrap_or_else()` +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:12:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:13:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:13:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:16:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:15:15 + | +LL | let val = Some::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:17:17 + | +LL | let _val2 = val.expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:15:15 + | +LL | let val = Some::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `None` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:22:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `None` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:21:15 + | +LL | let val = None::<()>; + | ^^^^^^^^^^ + +error: used `expect()` on `None` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:23:17 + | +LL | let _val2 = val.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `None` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:21:15 + | +LL | let val = None::<()>; + | ^^^^^^^^^^ + +error: used `unwrap()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:28:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `expect()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:29:17 + | +LL | let _val2 = val.expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:30:17 + | +LL | let _val2 = val.unwrap_err(); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:31:17 + | +LL | let _val2 = val.expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:27:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:35:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:35:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:36:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:36:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:37:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:37:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:38:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:38:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:41:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:42:17 + | +LL | let _val2 = val.expect("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:43:17 + | +LL | let _val2 = val.unwrap_err(); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:44:17 + | +LL | let _val2 = val.expect_err("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:40:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:49:17 + | +LL | let _val2 = val.unwrap_err(); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15 + | +LL | let val = Err::<(), _>(1); + | ^^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:50:17 + | +LL | let _val2 = val.expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15 + | +LL | let val = Err::<(), _>(1); + | ^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:51:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15 + | +LL | let val = Err::<(), _>(1); + | ^^^^^^^^^^^^^^^ + +error: used `expect()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:52:17 + | +LL | let _val2 = val.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:48:15 + | +LL | let val = Err::<(), _>(1); + | ^^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:56:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:56:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap_err(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:57:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:58:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:58:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).unwrap(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:59:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:59:16 + | +LL | let _val = Err::<(), usize>([1, 2, 3].iter().sum()).expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:62:17 + | +LL | let _val2 = val.unwrap_err(); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15 + | +LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect_err()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:63:17 + | +LL | let _val2 = val.expect_err("this never happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect_err()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15 + | +LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:64:17 + | +LL | let _val2 = val.unwrap(); + | ^^^^^^^^^^^^ + | +help: remove the `Err` and `unwrap()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15 + | +LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `expect()` on `Err` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:65:17 + | +LL | let _val2 = val.expect("this always happens"); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Err` and `expect()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:61:15 + | +LL | let val = Err::<(), usize>([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:70:17 + | +LL | let _val2 = val.unwrap_or(2); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15 + | +LL | let val = Some(1); + | ^^^^^^^ + +error: used `unwrap_or_default()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:71:17 + | +LL | let _val2 = val.unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15 + | +LL | let val = Some(1); + | ^^^^^^^ + +error: used `unwrap_or_else()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:72:17 + | +LL | let _val2 = val.unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_else()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:69:15 + | +LL | let val = Some(1); + | ^^^^^^^ + +error: used `unwrap_or()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:76:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:76:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_default()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:77:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_else()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:78:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_else()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:78:16 + | +LL | let _val = Some::([1, 2, 3].iter().sum()).unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:81:17 + | +LL | let _val2 = val.unwrap_or(2); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15 + | +LL | let val = Some::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_default()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:82:17 + | +LL | let _val2 = val.unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15 + | +LL | let val = Some::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_else()` on `Some` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:83:17 + | +LL | let _val2 = val.unwrap_or_else(|| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Some` and `unwrap_or_else()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:80:15 + | +LL | let val = Some::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:88:17 + | +LL | let _val2 = val.unwrap_or(2); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `unwrap_or_default()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:89:17 + | +LL | let _val2 = val.unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `unwrap_or_else()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:90:17 + | +>>>>>>> 6cf138e9b (Add more tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) +LL | let _val2 = val.unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_else()` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15 + | +LL | let val = Ok::<_, ()>(1); + | ^^^^^^^^^^^^^^ + +error: used `unwrap_or()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or(2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_default()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:95:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:95:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_else()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_else()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:96:16 + | +LL | let _val = Ok::([1, 2, 3].iter().sum()).unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:99:17 + | +LL | let _val2 = val.unwrap_or(2); + | ^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_default()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:100:17 + | +LL | let _val2 = val.unwrap_or_default(); + | ^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_default()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: used `unwrap_or_else()` on `Ok` value + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:101:17 + | +LL | let _val2 = val.unwrap_or_else(|_| 2); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `Ok` and `unwrap_or_else()` + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:98:15 + | +LL | let val = Ok::([1, 2, 3].iter().sum()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 50 previous errors +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +error: aborting due to previous error +>>>>>>> 6e0e09c8f (Track init and unwrap of expr) +======= + --> $DIR/unnecessary_literal_unwrap_unfixable.rs:41:15 +======= --> $DIR/unnecessary_literal_unwrap_unfixable.rs:87:15 +>>>>>>> 6e4c5561b (Preserve type annotations when present) | LL | let val = Ok::<_, ()>(1); | ^^^^^^^^^^^^^^ +<<<<<<< HEAD +error: aborting due to 18 previous errors +>>>>>>> 6cf138e9b (Add more tests) +======= error: used `unwrap_or()` on `Ok` value --> $DIR/unnecessary_literal_unwrap_unfixable.rs:94:16 | @@ -600,4 +1257,8 @@ LL | let val = Ok::([1, 2, 3].iter().sum()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 50 previous errors +>>>>>>> 6e4c5561b (Preserve type annotations when present) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/unnecessary_struct_initialization.fixed b/tests/ui/unnecessary_struct_initialization.fixed index eae1271d1aa7..b6771e5d9fe3 100644 --- a/tests/ui/unnecessary_struct_initialization.fixed +++ b/tests/ui/unnecessary_struct_initialization.fixed @@ -1,6 +1,22 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +======= +#![allow(clippy::needless_clone_impl, unused)] +>>>>>>> 67d5e6ec3 (add lint [`needless_clone_impl`]) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +>>>>>>> 10cc1684c (rename lint and disallow `clone_from`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::unnecessary_struct_initialization)] struct S { diff --git a/tests/ui/unnecessary_struct_initialization.rs b/tests/ui/unnecessary_struct_initialization.rs index 4abd560f84be..d269f6bbae6a 100644 --- a/tests/ui/unnecessary_struct_initialization.rs +++ b/tests/ui/unnecessary_struct_initialization.rs @@ -1,6 +1,22 @@ //@run-rustfix +<<<<<<< HEAD +<<<<<<< HEAD #![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +======= +#![allow(clippy::needless_clone_impl, unused)] +>>>>>>> 67d5e6ec3 (add lint [`needless_clone_impl`]) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +>>>>>>> 10cc1684c (rename lint and disallow `clone_from`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![allow(clippy::incorrect_clone_impl_on_copy_type, unused)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![warn(clippy::unnecessary_struct_initialization)] struct S { diff --git a/tests/ui/unneeded_wildcard_pattern.fixed b/tests/ui/unneeded_wildcard_pattern.fixed index 2eeba509e833..04e2d0fef823 100644 --- a/tests/ui/unneeded_wildcard_pattern.fixed +++ b/tests/ui/unneeded_wildcard_pattern.fixed @@ -3,6 +3,18 @@ #![feature(stmt_expr_attributes)] #![deny(clippy::unneeded_wildcard_pattern)] #![allow(clippy::needless_if)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + +#[macro_use] +extern crate proc_macros; +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[macro_use] extern crate proc_macros; diff --git a/tests/ui/unneeded_wildcard_pattern.rs b/tests/ui/unneeded_wildcard_pattern.rs index 5416cfaa5425..a794b4c270b7 100644 --- a/tests/ui/unneeded_wildcard_pattern.rs +++ b/tests/ui/unneeded_wildcard_pattern.rs @@ -3,6 +3,18 @@ #![feature(stmt_expr_attributes)] #![deny(clippy::unneeded_wildcard_pattern)] #![allow(clippy::needless_if)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD + +#[macro_use] +extern crate proc_macros; +======= +>>>>>>> 26f50395b (Add `needless_if` lint) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #[macro_use] extern crate proc_macros; diff --git a/tests/ui/unneeded_wildcard_pattern.stderr b/tests/ui/unneeded_wildcard_pattern.stderr index ffbdc049506e..77ba7a22256c 100644 --- a/tests/ui/unneeded_wildcard_pattern.stderr +++ b/tests/ui/unneeded_wildcard_pattern.stderr @@ -1,5 +1,21 @@ error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:13:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:13:18 +======= + --> $DIR/unneeded_wildcard_pattern.rs:9:18 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:13:18 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:13:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, .., _) = t {}; | ^^^ help: remove it @@ -11,79 +27,287 @@ LL | #![deny(clippy::unneeded_wildcard_pattern)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:14:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:14:16 +======= + --> $DIR/unneeded_wildcard_pattern.rs:10:16 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:14:16 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unneeded_wildcard_pattern.rs:14:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, _, ..) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:15:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:15:13 +======= + --> $DIR/unneeded_wildcard_pattern.rs:11:13 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:15:13 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:15:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (_, .., 0) = t {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:16:15 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:16:15 +======= + --> $DIR/unneeded_wildcard_pattern.rs:12:15 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unneeded_wildcard_pattern.rs:16:15 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:16:15 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (.., _, 0) = t {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:17:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:17:16 +======= + --> $DIR/unneeded_wildcard_pattern.rs:13:16 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unneeded_wildcard_pattern.rs:17:16 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:17:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, _, _, ..) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:18:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:18:18 +======= + --> $DIR/unneeded_wildcard_pattern.rs:14:18 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:18:18 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:18:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, .., _, _) = t {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:27:22 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:27:22 +======= + --> $DIR/unneeded_wildcard_pattern.rs:23:22 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:27:22 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unneeded_wildcard_pattern.rs:27:22 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, .., _, _,) = t {}; | ^^^^^^ help: remove them error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:34:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:34:19 +======= + --> $DIR/unneeded_wildcard_pattern.rs:30:19 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:34:19 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:34:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(0, .., _) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:35:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:35:17 +======= + --> $DIR/unneeded_wildcard_pattern.rs:31:17 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:35:17 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unneeded_wildcard_pattern.rs:35:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(0, _, ..) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:36:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:36:14 +======= + --> $DIR/unneeded_wildcard_pattern.rs:32:14 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:36:14 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:36:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(_, .., 0) = s {}; | ^^^ help: remove it error: this pattern is unneeded as the `..` pattern can match that element +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:37:16 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:37:16 +======= + --> $DIR/unneeded_wildcard_pattern.rs:33:16 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unneeded_wildcard_pattern.rs:37:16 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:37:16 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(.., _, 0) = s {}; | ^^^ help: remove it error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:38:17 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:38:17 +======= + --> $DIR/unneeded_wildcard_pattern.rs:34:17 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unneeded_wildcard_pattern.rs:38:17 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:38:17 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(0, _, _, ..) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:39:19 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unneeded_wildcard_pattern.rs:39:19 +======= + --> $DIR/unneeded_wildcard_pattern.rs:35:19 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:39:19 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unneeded_wildcard_pattern.rs:39:19 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(0, .., _, _) = s {}; | ^^^^^^ help: remove them error: these patterns are unneeded as the `..` pattern can match those elements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:48:23 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unneeded_wildcard_pattern.rs:48:23 +======= + --> $DIR/unneeded_wildcard_pattern.rs:44:23 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unneeded_wildcard_pattern.rs:48:23 +>>>>>>> d29506794 (Don't lint code from external macros) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unneeded_wildcard_pattern.rs:48:23 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S(0, .., _, _,) = s {}; | ^^^^^^ help: remove them diff --git a/tests/ui/unnested_or_patterns.fixed b/tests/ui/unnested_or_patterns.fixed index 738045595c0b..df5b0e64b3cd 100644 --- a/tests/ui/unnested_or_patterns.fixed +++ b/tests/ui/unnested_or_patterns.fixed @@ -6,8 +6,31 @@ clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_if, clippy::manual_range_patterns +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_if, + clippy::manual_range_patterns +======= + clippy::needless_if +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + clippy::needless_if, +<<<<<<< HEAD + clippy::manual_range_pattern +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +======= + clippy::manual_range_patterns +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_if, + clippy::manual_range_patterns +>>>>>>> 615b25c20 (Rebase attempt number 2) )] #![allow(unreachable_patterns, irrefutable_let_patterns, unused)] diff --git a/tests/ui/unnested_or_patterns.rs b/tests/ui/unnested_or_patterns.rs index 9e0e7b5def98..0e8714206801 100644 --- a/tests/ui/unnested_or_patterns.rs +++ b/tests/ui/unnested_or_patterns.rs @@ -6,8 +6,31 @@ clippy::cognitive_complexity, clippy::match_ref_pats, clippy::upper_case_acronyms, +<<<<<<< HEAD +<<<<<<< HEAD clippy::needless_if, clippy::manual_range_patterns +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::needless_if, + clippy::manual_range_patterns +======= + clippy::needless_if +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + clippy::needless_if, +<<<<<<< HEAD + clippy::manual_range_pattern +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +======= + clippy::manual_range_patterns +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::needless_if, + clippy::manual_range_patterns +>>>>>>> 615b25c20 (Rebase attempt number 2) )] #![allow(unreachable_patterns, irrefutable_let_patterns, unused)] diff --git a/tests/ui/unnested_or_patterns.stderr b/tests/ui/unnested_or_patterns.stderr index b997e4ce85fb..61124a67dbb4 100644 --- a/tests/ui/unnested_or_patterns.stderr +++ b/tests/ui/unnested_or_patterns.stderr @@ -1,5 +1,21 @@ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnested_or_patterns.rs:18:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:18:12 +======= + --> $DIR/unnested_or_patterns.rs:17:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:18:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:18:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let box 0 | box 2 = Box::new(0) {} | ^^^^^^^^^^^^^ @@ -11,7 +27,23 @@ LL | if let box (0 | 2) = Box::new(0) {} | ~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:19:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnested_or_patterns.rs:19:12 +======= + --> $DIR/unnested_or_patterns.rs:18:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:19:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:19:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let box ((0 | 1)) | box (2 | 3) | box 4 = Box::new(0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,7 +54,23 @@ LL | if let box (0 | 1 | 2 | 3 | 4) = Box::new(0) {} | ~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:21:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnested_or_patterns.rs:21:12 +======= + --> $DIR/unnested_or_patterns.rs:20:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:21:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:21:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let Some(1) | C0 | Some(2) = None {} | ^^^^^^^^^^^^^^^^^^^^^^ @@ -33,7 +81,23 @@ LL | if let Some(1 | 2) | C0 = None {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:22:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:22:12 +======= + --> $DIR/unnested_or_patterns.rs:21:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:22:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:22:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let &mut 0 | &mut 2 = &mut 0 {} | ^^^^^^^^^^^^^^^ @@ -44,7 +108,23 @@ LL | if let &mut (0 | 2) = &mut 0 {} | ~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:23:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:23:12 +======= + --> $DIR/unnested_or_patterns.rs:22:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:23:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:23:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let x @ 0 | x @ 2 = 0 {} | ^^^^^^^^^^^^^ @@ -55,7 +135,23 @@ LL | if let x @ (0 | 2) = 0 {} | ~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:24:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:24:12 +======= + --> $DIR/unnested_or_patterns.rs:23:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:24:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:24:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (0, 1) | (0, 2) | (0, 3) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -66,7 +162,23 @@ LL | if let (0, 1 | 2 | 3) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:25:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:25:12 +======= + --> $DIR/unnested_or_patterns.rs:24:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:25:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:25:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (1, 0) | (2, 0) | (3, 0) = (0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -77,7 +189,23 @@ LL | if let (1 | 2 | 3, 0) = (0, 0) {} | ~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:26:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:26:12 +======= + --> $DIR/unnested_or_patterns.rs:25:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:26:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:26:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let (x, ..) | (x, 1) | (x, 2) = (0, 1) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -88,7 +216,23 @@ LL | if let (x, ..) | (x, 1 | 2) = (0, 1) {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unnested_or_patterns.rs:27:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:27:12 +======= + --> $DIR/unnested_or_patterns.rs:26:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:27:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:27:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let [0] | [1] = [0] {} | ^^^^^^^^^ @@ -99,7 +243,23 @@ LL | if let [0 | 1] = [0] {} | ~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:28:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:28:12 +======= + --> $DIR/unnested_or_patterns.rs:27:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:28:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:28:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let [x, 0] | [x, 1] = [0, 1] {} | ^^^^^^^^^^^^^^^ @@ -110,7 +270,23 @@ LL | if let [x, 0 | 1] = [0, 1] {} | ~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:29:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:29:12 +======= + --> $DIR/unnested_or_patterns.rs:28:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:29:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:29:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let [x, 0] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -121,7 +297,23 @@ LL | if let [x, 0 | 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:30:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:30:12 +======= + --> $DIR/unnested_or_patterns.rs:29:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:30:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:30:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let [x, ..] | [x, 1] | [x, 2] = [0, 1] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +324,23 @@ LL | if let [x, ..] | [x, 1 | 2] = [0, 1] {} | ~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:32:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:32:12 +======= + --> $DIR/unnested_or_patterns.rs:31:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unnested_or_patterns.rs:32:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:32:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let TS(0, x) | TS(1, x) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^ @@ -143,7 +351,23 @@ LL | if let TS(0 | 1, x) = TS(0, 0) {} | ~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:33:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:33:12 +======= + --> $DIR/unnested_or_patterns.rs:32:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unnested_or_patterns.rs:33:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:33:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let TS(1, 0) | TS(2, 0) | TS(3, 0) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,7 +378,23 @@ LL | if let TS(1 | 2 | 3, 0) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:34:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:34:12 +======= + --> $DIR/unnested_or_patterns.rs:33:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= --> $DIR/unnested_or_patterns.rs:34:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unnested_or_patterns.rs:34:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let TS(x, ..) | TS(x, 1) | TS(x, 2) = TS(0, 0) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -165,7 +405,23 @@ LL | if let TS(x, ..) | TS(x, 1 | 2) = TS(0, 0) {} | ~~~~~~~~~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:39:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:39:12 +======= + --> $DIR/unnested_or_patterns.rs:38:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:39:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:39:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let S { x: 0, y } | S { y, x: 1 } = (S { x: 0, y: 1 }) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -176,7 +432,23 @@ LL | if let S { x: 0 | 1, y } = (S { x: 0, y: 1 }) {} | ~~~~~~~~~~~~~~~~~ error: unnested or-patterns +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:50:12 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unnested_or_patterns.rs:50:12 +======= + --> $DIR/unnested_or_patterns.rs:49:12 +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + --> $DIR/unnested_or_patterns.rs:50:12 +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unnested_or_patterns.rs:50:12 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | if let [1] | [53] = [0] {} | ^^^^^^^^^^ diff --git a/tests/ui/unnested_or_patterns2.fixed b/tests/ui/unnested_or_patterns2.fixed index 11dc34378758..2bfab148120d 100644 --- a/tests/ui/unnested_or_patterns2.fixed +++ b/tests/ui/unnested_or_patterns2.fixed @@ -2,12 +2,44 @@ #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::cognitive_complexity, clippy::match_ref_pats, clippy::needless_if, +<<<<<<< HEAD +<<<<<<< HEAD clippy::manual_range_patterns )] +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::manual_range_patterns +)] +======= +#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::needless_if)] +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + clippy::manual_range_pattern +======= + clippy::manual_range_patterns +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +)] +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::manual_range_patterns +)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)] fn main() { diff --git a/tests/ui/unnested_or_patterns2.rs b/tests/ui/unnested_or_patterns2.rs index b25560827413..25a3ca5ef67c 100644 --- a/tests/ui/unnested_or_patterns2.rs +++ b/tests/ui/unnested_or_patterns2.rs @@ -2,12 +2,44 @@ #![feature(box_patterns)] #![warn(clippy::unnested_or_patterns)] +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow( clippy::cognitive_complexity, clippy::match_ref_pats, clippy::needless_if, +<<<<<<< HEAD +<<<<<<< HEAD clippy::manual_range_patterns )] +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::manual_range_patterns +)] +======= +#![allow(clippy::cognitive_complexity, clippy::match_ref_pats, clippy::needless_if)] +>>>>>>> 26f50395b (Add `needless_if` lint) +======= + clippy::manual_range_pattern +======= + clippy::manual_range_patterns +>>>>>>> b592d3996 (manual_range_pattern -> manual_range_patterns) +)] +>>>>>>> 1d4afc5d8 (new lint: `manual_range_pattern`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::manual_range_patterns +)] +>>>>>>> 615b25c20 (Rebase attempt number 2) #![allow(unreachable_patterns, irrefutable_let_patterns, unused_variables)] fn main() { diff --git a/tests/ui/unused_async.rs b/tests/ui/unused_async.rs index 69e46ab47362..9dfbd668c0cd 100644 --- a/tests/ui/unused_async.rs +++ b/tests/ui/unused_async.rs @@ -25,6 +25,16 @@ mod issue10800 { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) mod issue10459 { trait HasAsyncMethod { async fn do_something() -> u32; @@ -37,6 +47,17 @@ mod issue10459 { } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) async fn foo() -> i32 { 4 } diff --git a/tests/ui/unused_async.stderr b/tests/ui/unused_async.stderr index ffae8366b88c..0f8990e5d083 100644 --- a/tests/ui/unused_async.stderr +++ b/tests/ui/unused_async.stderr @@ -1,5 +1,21 @@ error: unused `async` for function with no await statements +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/unused_async.rs:13:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unused_async.rs:13:5 +======= + --> $DIR/unused_async.rs:11:5 +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + --> $DIR/unused_async.rs:13:5 +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/unused_async.rs:13:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / async fn async_block_await() { LL | | async { @@ -9,6 +25,14 @@ LL | | } | |_____^ | = help: consider removing the `async` from this function +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) note: `await` used in an async block, which does not require the enclosing function to be `async` --> $DIR/unused_async.rs:15:23 | @@ -18,6 +42,29 @@ LL | ready(()).await; error: unused `async` for function with no await statements --> $DIR/unused_async.rs:40:1 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + = note: `await` used in an async block, which does not require the enclosing function to be `async` +======= +note: `await` used in an async block, which does not require the enclosing function to be `async` + --> $DIR/unused_async.rs:13:23 + | +LL | ready(()).await; + | ^^^^^ +>>>>>>> 8ef6240af (point to `await` expr in note) + = note: `-D clippy::unused-async` implied by `-D warnings` + +error: unused `async` for function with no await statements + --> $DIR/unused_async.rs:26:1 +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / async fn foo() -> i32 { LL | | 4 @@ -27,7 +74,23 @@ LL | | } = help: consider removing the `async` from this function error: unused `async` for function with no await statements +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unused_async.rs:51:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/unused_async.rs:51:5 +======= + --> $DIR/unused_async.rs:37:5 +>>>>>>> 1e73a9eb4 (do not consider `await` in nested `async` blocks) +======= + --> $DIR/unused_async.rs:51:5 +>>>>>>> a43bfefd1 ([`unused_async`]: don't lint on async trait impls) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/unused_async.rs:51:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | / async fn unused(&self) -> i32 { LL | | 1 diff --git a/tests/ui/useless_conversion.stderr b/tests/ui/useless_conversion.stderr index 4957f73a469a..ffed37fa01c7 100644 --- a/tests/ui/useless_conversion.stderr +++ b/tests/ui/useless_conversion.stderr @@ -122,7 +122,23 @@ error: explicit call to `.into_iter()` in function argument accepting `IntoItera --> $DIR/useless_conversion.rs:171:7 | LL | b(vec![1, 2].into_iter()); +<<<<<<< HEAD +<<<<<<< HEAD | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2]` +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 615b25c20 (Rebase attempt number 2) | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> $DIR/useless_conversion.rs:161:13 @@ -134,7 +150,23 @@ error: explicit call to `.into_iter()` in function argument accepting `IntoItera --> $DIR/useless_conversion.rs:172:7 | LL | c(vec![1, 2].into_iter()); +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= +<<<<<<< HEAD +<<<<<<< HEAD | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2]` +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 615b25c20 (Rebase attempt number 2) | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> $DIR/useless_conversion.rs:162:18 @@ -146,7 +178,23 @@ error: explicit call to `.into_iter()` in function argument accepting `IntoItera --> $DIR/useless_conversion.rs:173:7 | LL | d(vec![1, 2].into_iter()); +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2]` +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + | ^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`: `vec![1, 2]` +>>>>>>> 615b25c20 (Rebase attempt number 2) | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> $DIR/useless_conversion.rs:165:12 @@ -158,7 +206,23 @@ error: explicit call to `.into_iter()` in function argument accepting `IntoItera --> $DIR/useless_conversion.rs:176:7 | LL | b(vec![1, 2].into_iter().into_iter()); +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2]` +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +>>>>>>> 615b25c20 (Rebase attempt number 2) | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> $DIR/useless_conversion.rs:161:13 @@ -170,7 +234,23 @@ error: explicit call to `.into_iter()` in function argument accepting `IntoItera --> $DIR/useless_conversion.rs:177:7 | LL | b(vec![1, 2].into_iter().into_iter().into_iter()); +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +======= +<<<<<<< HEAD +<<<<<<< HEAD + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into_iter()`: `vec![1, 2]` +>>>>>>> de1f41001 (merge `explicit_into_iter_fn_arg` into `useless_conversion`) +======= + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +>>>>>>> 5a7e33e5b (add plural form to useless_conversion if depth > 0) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing the `.into_iter()`s: `vec![1, 2]` +>>>>>>> 615b25c20 (Rebase attempt number 2) | note: this parameter accepts any `IntoIterator`, so you don't need to call `.into_iter()` --> $DIR/useless_conversion.rs:161:13 diff --git a/tests/ui/vec.fixed b/tests/ui/vec.fixed index 7a7d0026f797..f766b79f16ab 100644 --- a/tests/ui/vec.fixed +++ b/tests/ui/vec.fixed @@ -7,7 +7,23 @@ use std::rc::Rc; struct StructWithVec { _x: Vec, } - +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + +<<<<<<< HEAD +#[derive(Debug)] +struct NonCopy; +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) + +======= +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +======= + +>>>>>>> 615b25c20 (Rebase attempt number 2) fn on_slice(_: &[u8]) {} fn on_mut_slice(_: &mut [u8]) {} @@ -71,9 +87,30 @@ fn main() { println!("{:?}", a); } +<<<<<<< HEAD +<<<<<<< HEAD + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = [1, 2, 3].iter().sum(); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = [1, 2, 3].iter().sum(); + +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = [1, 2, 3].iter().sum(); + +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 let _x: i32 = [1, 2, 3].iter().sum(); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do lint let mut x = [1, 2, 3]; x.fill(123); @@ -83,7 +120,23 @@ fn main() { let _x: &[i32] = &[1, 2, 3]; +<<<<<<< HEAD +<<<<<<< HEAD + for _ in [1, 2, 3] {} +======= +<<<<<<< HEAD +<<<<<<< HEAD + for _ in [1, 2, 3] {} +======= + for _ in &[1, 2, 3] {} +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= for _ in [1, 2, 3] {} +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + for _ in [1, 2, 3] {} +>>>>>>> 615b25c20 (Rebase attempt number 2) // Don't lint let x = vec![1, 2, 3]; @@ -113,6 +166,37 @@ fn main() { // Too large let _x = vec![1; 201]; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +} + +#[clippy::msrv = "1.53"] +fn above() { + for a in [1, 2, 3] { + let _: usize = a; + } + + for a in [String::new(), String::new()] { + let _: String = a; + } +} + +#[clippy::msrv = "1.52"] +fn below() { + for a in vec![1, 2, 3] { + let _: usize = a; + } + + for a in vec![String::new(), String::new()] { + let _: String = a; + } +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn issue11075() { diff --git a/tests/ui/vec.rs b/tests/ui/vec.rs index cbe7685b4533..26f8a676a828 100644 --- a/tests/ui/vec.rs +++ b/tests/ui/vec.rs @@ -7,7 +7,23 @@ use std::rc::Rc; struct StructWithVec { _x: Vec, } - +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + +<<<<<<< HEAD +#[derive(Debug)] +struct NonCopy; +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) + +======= +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +======= + +>>>>>>> 615b25c20 (Rebase attempt number 2) fn on_slice(_: &[u8]) {} fn on_mut_slice(_: &mut [u8]) {} @@ -71,9 +87,30 @@ fn main() { println!("{:?}", a); } +<<<<<<< HEAD +<<<<<<< HEAD + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = vec![1, 2, 3].iter().sum(); + +======= +<<<<<<< HEAD +<<<<<<< HEAD + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = vec![1, 2, 3].iter().sum(); + +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 + let _x: i32 = vec![1, 2, 3].iter().sum(); + +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= // /~https://github.com/rust-lang/rust-clippy/issues/2262#issuecomment-783979246 let _x: i32 = vec![1, 2, 3].iter().sum(); +>>>>>>> 615b25c20 (Rebase attempt number 2) // Do lint let mut x = vec![1, 2, 3]; x.fill(123); @@ -113,6 +150,37 @@ fn main() { // Too large let _x = vec![1; 201]; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +} + +#[clippy::msrv = "1.53"] +fn above() { + for a in vec![1, 2, 3] { + let _: usize = a; + } + + for a in vec![String::new(), String::new()] { + let _: String = a; + } +} + +#[clippy::msrv = "1.52"] +fn below() { + for a in vec![1, 2, 3] { + let _: usize = a; + } + + for a in vec![String::new(), String::new()] { + let _: String = a; + } +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } fn issue11075() { diff --git a/tests/ui/vec.stderr b/tests/ui/vec.stderr index 8f6d2a1df803..ebbfddab73b6 100644 --- a/tests/ui/vec.stderr +++ b/tests/ui/vec.stderr @@ -1,5 +1,21 @@ error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/vec.rs:31:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:31:14 +======= + --> $DIR/vec.rs:34:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:31:14 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:31:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_slice(&vec![]); | ^^^^^^^ help: you can use a slice directly: `&[]` @@ -7,60 +23,215 @@ LL | on_slice(&vec![]); = note: `-D clippy::useless-vec` implied by `-D warnings` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:33:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:33:18 +======= + --> $DIR/vec.rs:36:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/vec.rs:33:18 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:33:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_mut_slice(&mut vec![]); | ^^^^^^^^^^^ help: you can use a slice directly: `&mut []` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:35:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:35:14 +======= + --> $DIR/vec.rs:38:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/vec.rs:35:14 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:35:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:37:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/vec.rs:37:18 +======= + --> $DIR/vec.rs:40:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:37:18 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:37:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:39:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:39:14 +======= + --> $DIR/vec.rs:42:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:39:14 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/vec.rs:39:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_slice(&vec![1, 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/vec.rs:41:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:41:18 +======= + --> $DIR/vec.rs:44:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:41:18 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:41:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:43:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:43:14 +======= + --> $DIR/vec.rs:46:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/vec.rs:43:14 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:43:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_slice(&vec!(1, 2)); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:45:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:45:18 +======= + --> $DIR/vec.rs:48:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/vec.rs:45:18 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:45:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_mut_slice(&mut vec![1, 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1, 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:47:14 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/vec.rs:47:14 +======= + --> $DIR/vec.rs:50:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:47:14 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/vec.rs:47:14 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_slice(&vec![1; 2]); | ^^^^^^^^^^^ help: you can use a slice directly: `&[1; 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:49:18 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/vec.rs:49:18 +======= + --> $DIR/vec.rs:52:18 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/vec.rs:49:18 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/vec.rs:49:18 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | on_mut_slice(&mut vec![1; 2]); | ^^^^^^^^^^^^^^^ help: you can use a slice directly: `&mut [1; 2]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 50ba45998 (add- and fix existing tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) --> $DIR/vec.rs:75:19 | LL | let _x: i32 = vec![1, 2, 3].iter().sum(); @@ -68,6 +239,13 @@ LL | let _x: i32 = vec![1, 2, 3].iter().sum(); error: useless use of `vec!` --> $DIR/vec.rs:78:17 +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | let mut x = vec![1, 2, 3]; | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` @@ -85,6 +263,8 @@ LL | for _ in vec![1, 2, 3] {} | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/vec.rs:124:20 | LL | for _string in vec![repro!(true), repro!(null)] { @@ -104,15 +284,109 @@ LL | in_macro!(1, vec![1, 2], vec![1; 2]); error: useless use of `vec!` --> $DIR/vec.rs:160:14 +======= +<<<<<<< HEAD + --> $DIR/vec.rs:120:14 +======= + --> $DIR/vec.rs:69:14 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +>>>>>>> 0567691cb (This commit resolves issue #10655) | LL | for a in vec![1, 2, 3] { | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` error: useless use of `vec!` +<<<<<<< HEAD +======= +<<<<<<< HEAD + --> $DIR/vec.rs:124:14 + | +LL | for a in vec![String::new(), String::new()] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` + +error: aborting due to 16 previous errors +======= + --> $DIR/vec.rs:86:17 +======= + --> $DIR/vec.rs:75:17 +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +======= +>>>>>>> 50ba45998 (add- and fix existing tests) + | +LL | let mut x = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` + +error: useless use of `vec!` + --> $DIR/vec.rs:84:22 + | +LL | let _x: &[i32] = &vec![1, 2, 3]; + | ^^^^^^^^^^^^^^ help: you can use a slice directly: `&[1, 2, 3]` + +error: useless use of `vec!` + --> $DIR/vec.rs:86:14 + | +LL | for _ in vec![1, 2, 3] {} + | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` + +<<<<<<< HEAD +error: aborting due to 14 previous errors +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= +error: useless use of `vec!` + --> $DIR/vec.rs:120:14 +======= +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + --> $DIR/vec.rs:124:20 + | +LL | for _string in vec![repro!(true), repro!(null)] { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[repro!(true), repro!(null)]` + +error: useless use of `vec!` + --> $DIR/vec.rs:141:18 + | +LL | in_macro!(1, vec![1, 2], vec![1; 2]); + | ^^^^^^^^^^ help: you can use an array directly: `[1, 2]` + +error: useless use of `vec!` + --> $DIR/vec.rs:141:30 + | +LL | in_macro!(1, vec![1, 2], vec![1; 2]); + | ^^^^^^^^^^ help: you can use an array directly: `[1; 2]` + +error: useless use of `vec!` + --> $DIR/vec.rs:160:14 + | +LL | for a in vec![1, 2, 3] { + | ^^^^^^^^^^^^^ help: you can use an array directly: `[1, 2, 3]` + +error: useless use of `vec!` +>>>>>>> 0567691cb (This commit resolves issue #10655) --> $DIR/vec.rs:164:14 | LL | for a in vec![String::new(), String::new()] { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: you can use an array directly: `[String::new(), String::new()]` +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 19 previous errors +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +error: aborting due to 15 previous errors +>>>>>>> 96697d2ee (Fix `useless_vec` suggestion in `for _ in vec![..]`) +======= +error: aborting due to 16 previous errors +>>>>>>> 50ba45998 (add- and fix existing tests) +======= +error: aborting due to 17 previous errors +>>>>>>> 1f77f8cc3 ([`useless_vec`]: use the source span) +======= +error: aborting due to 19 previous errors +>>>>>>> b4549c50b ([`useless_vec`]: add more tests for macro combinations) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= error: aborting due to 19 previous errors +>>>>>>> 615b25c20 (Rebase attempt number 2) diff --git a/tests/ui/while_let_on_iterator.fixed b/tests/ui/while_let_on_iterator.fixed index 41a380ab8f6a..71e773e67ae6 100644 --- a/tests/ui/while_let_on_iterator.fixed +++ b/tests/ui/while_let_on_iterator.fixed @@ -6,7 +6,22 @@ clippy::manual_find, clippy::never_loop, clippy::redundant_closure_call, +<<<<<<< HEAD +<<<<<<< HEAD clippy::single_range_in_vec_init, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::single_range_in_vec_init, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::single_range_in_vec_init, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::single_range_in_vec_init, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::uninlined_format_args, clippy::useless_vec )] diff --git a/tests/ui/while_let_on_iterator.rs b/tests/ui/while_let_on_iterator.rs index 4c6433880b63..254b4d9d7209 100644 --- a/tests/ui/while_let_on_iterator.rs +++ b/tests/ui/while_let_on_iterator.rs @@ -6,7 +6,22 @@ clippy::manual_find, clippy::never_loop, clippy::redundant_closure_call, +<<<<<<< HEAD +<<<<<<< HEAD clippy::single_range_in_vec_init, +======= +<<<<<<< HEAD +<<<<<<< HEAD + clippy::single_range_in_vec_init, +======= +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + clippy::single_range_in_vec_init, +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + clippy::single_range_in_vec_init, +>>>>>>> 615b25c20 (Rebase attempt number 2) clippy::uninlined_format_args, clippy::useless_vec )] diff --git a/tests/ui/while_let_on_iterator.stderr b/tests/ui/while_let_on_iterator.stderr index 3236765e1db0..dfab08b53cfd 100644 --- a/tests/ui/while_let_on_iterator.stderr +++ b/tests/ui/while_let_on_iterator.stderr @@ -1,5 +1,21 @@ error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:16:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:16:5 +======= + --> $DIR/while_let_on_iterator.rs:15:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:16:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:16:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Option::Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` @@ -7,151 +23,551 @@ LL | while let Option::Some(x) = iter.next() { = note: `-D clippy::while-let-on-iterator` implied by `-D warnings` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:21:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:21:5 +======= + --> $DIR/while_let_on_iterator.rs:20:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:21:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:21:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = iter.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in iter` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:26:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:26:5 +======= + --> $DIR/while_let_on_iterator.rs:25:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:26:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:26:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(_) = iter.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in iter` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:102:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:102:9 +======= + --> $DIR/while_let_on_iterator.rs:101:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:102:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:102:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some([..]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [..] in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:109:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:109:9 +======= + --> $DIR/while_let_on_iterator.rs:108:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:109:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:109:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some([_x]) = it.next() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for [_x] in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:122:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:122:9 +======= + --> $DIR/while_let_on_iterator.rs:121:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:122:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:122:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x @ [_]) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x @ [_] in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:142:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:142:9 +======= + --> $DIR/while_let_on_iterator.rs:141:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:142:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:142:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(_) = y.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in y` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:199:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:199:9 +======= + --> $DIR/while_let_on_iterator.rs:198:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:199:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:199:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:210:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:210:5 +======= + --> $DIR/while_let_on_iterator.rs:209:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:210:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:210:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:212:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:212:9 +======= + --> $DIR/while_let_on_iterator.rs:211:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:212:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:212:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:221:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:221:9 +======= + --> $DIR/while_let_on_iterator.rs:220:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:221:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:221:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:230:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:230:9 +======= + --> $DIR/while_let_on_iterator.rs:229:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:230:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:230:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:247:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:247:9 +======= + --> $DIR/while_let_on_iterator.rs:246:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:247:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:247:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(m) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for m in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:262:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:262:13 +======= + --> $DIR/while_let_on_iterator.rs:261:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:262:13 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:262:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(i) = self.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:294:13 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:294:13 +======= + --> $DIR/while_let_on_iterator.rs:293:13 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:294:13 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:294:13 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(i) = self.0.0.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for i in self.0.0.0.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:323:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:323:5 +======= + --> $DIR/while_let_on_iterator.rs:322:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:323:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:323:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(n) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for n in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:335:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:335:9 +======= + --> $DIR/while_let_on_iterator.rs:334:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:335:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:335:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:349:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:349:5 +======= + --> $DIR/while_let_on_iterator.rs:348:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:349:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:349:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:360:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:360:5 +======= + --> $DIR/while_let_on_iterator.rs:359:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:360:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:360:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.0.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.0.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:395:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:395:5 +======= + --> $DIR/while_let_on_iterator.rs:394:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:395:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:395:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = s.x.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in s.x.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:402:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:402:5 +======= + --> $DIR/while_let_on_iterator.rs:401:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:402:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:402:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = x[0].next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in x[0].by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:410:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:410:9 +======= + --> $DIR/while_let_on_iterator.rs:409:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:410:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:410:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:420:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:420:9 +======= + --> $DIR/while_let_on_iterator.rs:419:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:420:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:420:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD --> $DIR/while_let_on_iterator.rs:430:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:430:9 +======= + --> $DIR/while_let_on_iterator.rs:429:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:430:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:430:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it.by_ref()` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:440:9 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:440:9 +======= + --> $DIR/while_let_on_iterator.rs:439:9 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= --> $DIR/while_let_on_iterator.rs:440:9 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + --> $DIR/while_let_on_iterator.rs:440:9 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(x) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in it` error: this loop could be written as a `for` loop +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:450:5 +======= +<<<<<<< HEAD +<<<<<<< HEAD + --> $DIR/while_let_on_iterator.rs:450:5 +======= + --> $DIR/while_let_on_iterator.rs:449:5 +>>>>>>> 05f78e530 (allow the lint in a bunch of tests) +======= + --> $DIR/while_let_on_iterator.rs:450:5 +>>>>>>> 6702c7a7a (Add lint [`single_range_in_vec_init`]) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= --> $DIR/while_let_on_iterator.rs:450:5 +>>>>>>> 615b25c20 (Rebase attempt number 2) | LL | while let Some(..) = it.next() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for _ in it` diff --git a/tests/ui/write_literal_2.rs b/tests/ui/write_literal_2.rs index 805127e27500..6c76fe7380da 100644 --- a/tests/ui/write_literal_2.rs +++ b/tests/ui/write_literal_2.rs @@ -1,5 +1,21 @@ #![allow(unused_must_use)] +<<<<<<< HEAD +<<<<<<< HEAD #![warn(clippy::needless_raw_strings, clippy::write_literal)] +======= +<<<<<<< HEAD +<<<<<<< HEAD +#![warn(clippy::needless_raw_strings, clippy::write_literal)] +======= +#![warn(clippy::needless_raw_string, clippy::write_literal)] +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= +#![warn(clippy::needless_raw_strings, clippy::write_literal)] +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +#![warn(clippy::needless_raw_strings, clippy::write_literal)] +>>>>>>> 615b25c20 (Rebase attempt number 2) use std::io::Write; diff --git a/tests/ui/write_literal_2.stderr b/tests/ui/write_literal_2.stderr index c30ec385b35a..23dc54e4466a 100644 --- a/tests/ui/write_literal_2.stderr +++ b/tests/ui/write_literal_2.stderr @@ -4,7 +4,23 @@ error: unnecessary raw string literal LL | writeln!(v, r"{}", r"{hello}"); | ^^^^^^^^^^ help: try: `"{hello}"` | +<<<<<<< HEAD +<<<<<<< HEAD = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +======= +<<<<<<< HEAD +<<<<<<< HEAD + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +======= + = note: `-D clippy::needless-raw-string` implied by `-D warnings` +>>>>>>> bc744eb82 (new lint `needless_raw_string` + refactor a bit) +======= + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +>>>>>>> 8cb6c8699 (change category and refactor) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + = note: `-D clippy::needless-raw-strings` implied by `-D warnings` +>>>>>>> 615b25c20 (Rebase attempt number 2) error: literal with an empty format string --> $DIR/write_literal_2.rs:9:23 diff --git a/util/gh-pages/script.js b/util/gh-pages/script.js index f59245e556cd..3c27b8477e08 100644 --- a/util/gh-pages/script.js +++ b/util/gh-pages/script.js @@ -106,7 +106,23 @@ } }; }) +<<<<<<< HEAD +<<<<<<< HEAD .controller("lintList", function ($scope, $http, $location, $timeout) { +======= +<<<<<<< HEAD +<<<<<<< HEAD + .controller("lintList", function ($scope, $http, $location, $timeout) { +======= + .controller("lintList", function ($scope, $http, $location) { +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + .controller("lintList", function ($scope, $http, $location, $timeout) { +>>>>>>> a865d8432 (Clippy Lints page - Delay updating of the URL in response to search input) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + .controller("lintList", function ($scope, $http, $location, $timeout) { +>>>>>>> 615b25c20 (Rebase attempt number 2) // Level filter var LEVEL_FILTERS_DEFAULT = {allow: true, warn: true, deny: true, none: true}; $scope.levels = { ...LEVEL_FILTERS_DEFAULT }; @@ -163,7 +179,23 @@ const urlParameters = $location.search(); // Define a helper function that assigns URL parameters to a provided scope variable +<<<<<<< HEAD +<<<<<<< HEAD + const handleParameter = (parameter, scopeVariable, defaultValues) => { +======= +<<<<<<< HEAD +<<<<<<< HEAD + const handleParameter = (parameter, scopeVariable, defaultValues) => { +======= + const handleParameter = (parameter, scopeVariable) => { +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= const handleParameter = (parameter, scopeVariable, defaultValues) => { +>>>>>>> 7c1bca4be (Handle back/forward when using URL parameters for filter states) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + const handleParameter = (parameter, scopeVariable, defaultValues) => { +>>>>>>> 615b25c20 (Rebase attempt number 2) if (urlParameters[parameter]) { const items = urlParameters[parameter].split(','); for (const key in scopeVariable) { @@ -171,17 +203,54 @@ scopeVariable[key] = items.includes(key); } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 7c1bca4be (Handle back/forward when using URL parameters for filter states) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } else if (defaultValues) { for (const key in defaultValues) { if (scopeVariable.hasOwnProperty(key)) { scopeVariable[key] = defaultValues[key]; } } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + } + }; + + handleParameter('levels', $scope.levels, LEVEL_FILTERS_DEFAULT); + handleParameter('groups', $scope.groups, GROUPS_FILTER_DEFAULT); +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + } + }; + + handleParameter('levels', $scope.levels); + handleParameter('groups', $scope.groups); +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= } }; handleParameter('levels', $scope.levels, LEVEL_FILTERS_DEFAULT); handleParameter('groups', $scope.groups, GROUPS_FILTER_DEFAULT); +>>>>>>> 7c1bca4be (Handle back/forward when using URL parameters for filter states) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // Handle 'versions' parameter separately because it needs additional processing if (urlParameters.versions) { @@ -207,6 +276,14 @@ $scope.open[searchParameter] = true; scrollToLintByURL($scope, $location); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } // updateURLParameter updates the URL parameter with the given key to the given value @@ -214,10 +291,45 @@ const parameter = Object.keys(filterObj) .filter(filter => filterObj[filter]) .sort() +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= + + // If there are any filters in the URL, mark that the filters have been changed + if (urlParameters.levels || urlParameters.groups || urlParameters.versions) { + $scope.filtersChanged = true; + } +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) + } + + // updateURLParameter updates the URL parameter with the given key to the given value + function updateURLParameter(filterObj, urlKey, defaultValue = {}, processFilter = filter => filter) { + const parameter = Object.keys(filterObj) + .filter(filter => filterObj[filter]) +<<<<<<< HEAD +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + .sort() +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) .map(processFilter) .filter(Boolean) // Filters out any falsy values, including null .join(','); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) const defaultParameter = Object.keys(defaultValue) .filter(filter => defaultValue[filter]) .sort() @@ -231,13 +343,41 @@ } else { $location.search(urlKey, parameter || null); } +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +======= + $location.search(urlKey, parameter || null); +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) } // updateVersionURLParameter updates the version URL parameter with the given version filters function updateVersionURLParameter(versionFilters) { updateURLParameter( versionFilters, +<<<<<<< HEAD +<<<<<<< HEAD + 'versions', {}, +======= +<<<<<<< HEAD +<<<<<<< HEAD + 'versions', {}, +======= + 'versions', +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + 'versions', {}, +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= 'versions', {}, +>>>>>>> 615b25c20 (Rebase attempt number 2) versionFilter => versionFilters[versionFilter].enabled && versionFilters[versionFilter].minorVersion != null ? `${versionFilterKeyMap[versionFilter]}:${versionFilters[versionFilter].minorVersion}` : null @@ -246,32 +386,132 @@ // updateAllURLParameters updates all the URL parameters with the current filter settings function updateAllURLParameters() { +<<<<<<< HEAD +<<<<<<< HEAD updateURLParameter($scope.levels, 'levels', LEVEL_FILTERS_DEFAULT); updateURLParameter($scope.groups, 'groups', GROUPS_FILTER_DEFAULT); +======= +<<<<<<< HEAD +<<<<<<< HEAD + updateURLParameter($scope.levels, 'levels', LEVEL_FILTERS_DEFAULT); + updateURLParameter($scope.groups, 'groups', GROUPS_FILTER_DEFAULT); +======= + updateURLParameter($scope.levels, 'levels'); + updateURLParameter($scope.groups, 'groups'); +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + updateURLParameter($scope.levels, 'levels', LEVEL_FILTERS_DEFAULT); + updateURLParameter($scope.groups, 'groups', GROUPS_FILTER_DEFAULT); +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + updateURLParameter($scope.levels, 'levels', LEVEL_FILTERS_DEFAULT); + updateURLParameter($scope.groups, 'groups', GROUPS_FILTER_DEFAULT); +>>>>>>> 615b25c20 (Rebase attempt number 2) updateVersionURLParameter($scope.versionFilters); } // Add $watches to automatically update URL parameters when the data changes $scope.$watch('levels', function (newVal, oldVal) { if (newVal !== oldVal) { +<<<<<<< HEAD +<<<<<<< HEAD + updateURLParameter(newVal, 'levels', LEVEL_FILTERS_DEFAULT); +======= +<<<<<<< HEAD +<<<<<<< HEAD + updateURLParameter(newVal, 'levels', LEVEL_FILTERS_DEFAULT); +======= + $scope.filtersChanged = true; + updateURLParameter(newVal, 'levels'); +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= updateURLParameter(newVal, 'levels', LEVEL_FILTERS_DEFAULT); +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + updateURLParameter(newVal, 'levels', LEVEL_FILTERS_DEFAULT); +>>>>>>> 615b25c20 (Rebase attempt number 2) } }, true); $scope.$watch('groups', function (newVal, oldVal) { if (newVal !== oldVal) { +<<<<<<< HEAD +<<<<<<< HEAD + updateURLParameter(newVal, 'groups', GROUPS_FILTER_DEFAULT); +======= +<<<<<<< HEAD +<<<<<<< HEAD updateURLParameter(newVal, 'groups', GROUPS_FILTER_DEFAULT); +======= + $scope.filtersChanged = true; + updateURLParameter(newVal, 'groups'); +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + updateURLParameter(newVal, 'groups', GROUPS_FILTER_DEFAULT); +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + updateURLParameter(newVal, 'groups', GROUPS_FILTER_DEFAULT); +>>>>>>> 615b25c20 (Rebase attempt number 2) } }, true); $scope.$watch('versionFilters', function (newVal, oldVal) { if (newVal !== oldVal) { +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + $scope.filtersChanged = true; +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) updateVersionURLParameter(newVal); } }, true); +<<<<<<< HEAD +<<<<<<< HEAD + // Watch for changes in the URL path and update the search and lint display + $scope.$watch(function () { return $location.path(); }, function (newPath) { +======= +<<<<<<< HEAD +<<<<<<< HEAD // Watch for changes in the URL path and update the search and lint display $scope.$watch(function () { return $location.path(); }, function (newPath) { +<<<<<<< HEAD +======= + $scope.$watch('search', function (newVal, oldVal) { + if (newVal !== oldVal) { + $location.path(newVal); + } + }); + +======= +>>>>>>> a865d8432 (Clippy Lints page - Delay updating of the URL in response to search input) + // Watch for changes in the URL path and update the search and lint display +<<<<<<< HEAD + $scope.$watch(function () { + return $location.path(); + }, function (newPath) { +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= + $scope.$watch($location.path, function (newPath) { +>>>>>>> f2e6a99a0 (Clippy Lints page - Do not show groups in URL parameters if reset to defaults) +======= +>>>>>>> 2e4ef8e72 (Clippy Lints page - Fix path watch triggering) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + // Watch for changes in the URL path and update the search and lint display + $scope.$watch(function () { return $location.path(); }, function (newPath) { +>>>>>>> 615b25c20 (Rebase attempt number 2) const searchParameter = newPath.substring(1); if ($scope.search !== searchParameter) { $scope.search = searchParameter; @@ -280,6 +520,17 @@ } }); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> a865d8432 (Clippy Lints page - Delay updating of the URL in response to search input) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) let debounceTimeout; $scope.$watch('search', function (newVal, oldVal) { if (newVal !== oldVal) { @@ -293,10 +544,67 @@ } }); +<<<<<<< HEAD +<<<<<<< HEAD $scope.$watch(function () { return $location.search(); }, function (newParameters) { loadFromURLParameters(); }, true); +======= +<<<<<<< HEAD +<<<<<<< HEAD +<<<<<<< HEAD +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + $scope.$watch(function () { return $location.search(); }, function (newParameters) { + loadFromURLParameters(); + }, true); +<<<<<<< HEAD +======= + $scope.$watch($location.search, function (newParameters) { +======= + $scope.$watch(function () { return $location.search(); }, function (newParameters) { +>>>>>>> 2e4ef8e72 (Clippy Lints page - Fix path watch triggering) + if (!internalURLChange) { + loadFromURLParameters(); + } + internalURLChange = false; +<<<<<<< HEAD + }); +>>>>>>> f2e6a99a0 (Clippy Lints page - Do not show groups in URL parameters if reset to defaults) +======= +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) + }, true); +>>>>>>> 2e4ef8e72 (Clippy Lints page - Fix path watch triggering) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) + + $scope.updatePath = function () { + if (debounceTimeout) { + $timeout.cancel(debounceTimeout); + } + + $location.path($scope.search); + } + +<<<<<<< HEAD +<<<<<<< HEAD +======= +======= +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= +======= +>>>>>>> a865d8432 (Clippy Lints page - Delay updating of the URL in response to search input) + $scope.$watch(function () { + return $location.search(); + }, function (newParameters) { + loadFromURLParameters(); + }); +<<<<<<< HEAD +>>>>>>> 7c1bca4be (Handle back/forward when using URL parameters for filter states) +======= $scope.updatePath = function () { if (debounceTimeout) { $timeout.cancel(debounceTimeout); @@ -305,6 +613,10 @@ $location.path($scope.search); } +>>>>>>> a865d8432 (Clippy Lints page - Delay updating of the URL in response to search input) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) $scope.selectTheme = function (theme) { setTheme(theme, true); } @@ -328,9 +640,36 @@ }; $scope.resetGroupsToDefault = function () { +<<<<<<< HEAD +<<<<<<< HEAD + $scope.groups = { + ...GROUPS_FILTER_DEFAULT + }; +======= +<<<<<<< HEAD +<<<<<<< HEAD $scope.groups = { ...GROUPS_FILTER_DEFAULT }; +======= + const groups = $scope.groups; + for (const [key, value] of Object.entries(GROUPS_FILTER_DEFAULT)) { + groups[key] = value; + } + internalURLChange = true; + $location.search('groups', null); +>>>>>>> f2e6a99a0 (Clippy Lints page - Do not show groups in URL parameters if reset to defaults) +======= + $scope.groups = { + ...GROUPS_FILTER_DEFAULT + }; +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= + $scope.groups = { + ...GROUPS_FILTER_DEFAULT + }; +>>>>>>> 615b25c20 (Rebase attempt number 2) }; $scope.selectedValuesCount = function (obj) { @@ -434,6 +773,22 @@ $scope.openLint = function (lint) { $scope.open[lint.id] = true; $location.path(lint.id); +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + if ($scope.filtersChanged) { + updateAllURLParameters(); + $scope.filtersChanged = false; + } +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) }; $scope.copyToClipboard = function (lint) { @@ -460,6 +815,19 @@ // Get data $scope.open = {}; $scope.loading = true; +<<<<<<< HEAD +<<<<<<< HEAD +======= +<<<<<<< HEAD +<<<<<<< HEAD +======= + $scope.filtersChanged = false; +>>>>>>> 5be2b27ed (Use URL parameters for filter states) +======= +>>>>>>> ac279efdb (Clippy Lints page - Do not show filters in URL if configured as default values) +>>>>>>> 0567691cb (This commit resolves issue #10655) +======= +>>>>>>> 615b25c20 (Rebase attempt number 2) // This will be used to jump into the source code of the version that this documentation is for. $scope.docVersion = window.location.pathname.split('/')[2] || "master";