about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/visit.rs
AgeCommit message (Collapse)AuthorLines
2023-12-10remove redundant importssurechen-3/+1
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-11-08rename `BorrowKind::Shallow` to `Fake`lcnr-5/+5
also adds some comments
2023-10-20s/generator/coroutine/Oli Scherer-3/+3
2023-10-20s/Generator/Coroutine/Oli Scherer-2/+2
2023-10-06Rollup merge of #116277 - RalfJung:post-mono, r=oli-obkJubilee-0/+2
dont call mir.post_mono_checks in codegen It seems like all tests are still passing when I remove this... let's see what CI says.
2023-10-06add some comments explaining how the required_consts stuff fits togetherRalf Jung-0/+2
2023-10-04Remove mir::LocalDecl::internal.Camille GILLOT-1/+0
2023-10-02Add docs, remove code, change subtyper codeouz-a-1/+5
2023-10-02subtyping_projectionsouz-a-1/+4
2023-09-21rename mir::Constant -> mir::ConstOperand, mir::ConstKind -> mir::ConstRalf Jung-8/+8
2023-09-05Refactor how MIR represents composite debuginfo.Camille GILLOT-11/+8
2023-08-24when terminating during unwinding, show the reason whyRalf Jung-1/+1
2023-08-20give some unwind-related terminators a more clear nameRalf Jung-2/+2
2023-08-17Revert "Implement references VarDebugInfo."Camille GILLOT-1/+0
This reverts commit 2ec007191348ef7cc13eb55e44e007b02cf75cf3.
2023-07-14refactor(rustc_middle): Substs -> GenericArgMahdi Dibaiee-14/+14
2023-06-27Auto merge of #112693 - ericmarkmartin:use-more-placeref, r=spastorinobors-7/+4
Use PlaceRef abstractions more often Associated issue: https://github.com/rust-lang/rust/issues/80647 r? `@spastorino`
2023-06-25use PlaceRef abstractions more consistentlyEric Mark Martin-7/+4
2023-06-20merge `BorrowKind::Unique` into `BorrowKind::Mut`Ziru Niu-3/+0
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-1/+1
2023-05-29unique borrows are mutating useslcnr-7/+3
2023-05-25Remove DesugaringKind::Replace.Camille GILLOT-0/+1
2023-05-13Implement references VarDebugInfo.Camille GILLOT-0/+1
2023-05-12Auto merge of #109732 - Urgau:uplift_drop_forget_ref_lints, r=davidtwcobors-2/+1
Uplift `clippy::{drop,forget}_{ref,copy}` lints This PR aims at uplifting the `clippy::drop_ref`, `clippy::drop_copy`, `clippy::forget_ref` and `clippy::forget_copy` lints. Those lints are/were declared in the correctness category of clippy because they lint on useless and most probably is not what the developer wanted. ## `drop_ref` and `forget_ref` The `drop_ref` and `forget_ref` lint checks for calls to `std::mem::drop` or `std::mem::forget` with a reference instead of an owned value. ### Example ```rust let mut lock_guard = mutex.lock(); std::mem::drop(&lock_guard) // Should have been drop(lock_guard), mutex // still locked operation_that_requires_mutex_to_be_unlocked(); ``` ### Explanation Calling `drop` or `forget` on a reference will only drop the reference itself, which is a no-op. It will not call the `drop` or `forget` method on the underlying referenced value, which is likely what was intended. ## `drop_copy` and `forget_copy` The `drop_copy` and `forget_copy` lint checks for calls to `std::mem::forget` or `std::mem::drop` with a value that derives the Copy trait. ### Example ```rust let x: i32 = 42; // i32 implements Copy std::mem::forget(x) // A copy of x is passed to the function, leaving the // original unaffected ``` ### Explanation Calling `std::mem::forget` [does nothing for types that implement Copy](https://doc.rust-lang.org/std/mem/fn.drop.html) since the value will be copied and moved into the function on invocation. ----- Followed the instructions for uplift a clippy describe here: https://github.com/rust-lang/rust/pull/99696#pullrequestreview-1134072751 cc `@m-ou-se` (as T-libs-api leader because the uplifting was discussed in a recent meeting)
2023-05-10Remove and fix useless drop of referenceUrgau-2/+1
2023-05-10Make `NonUseContext::AscribeUserTy` carry `ty::Variance`Obei Sideg-4/+4
2023-05-04Rollup merge of #111100 - BoxyUwU:array_repeat_expr_wf, r=compiler-errorsMatthias Krüger-2/+19
check array type of repeat exprs is wf Fixes #111091 Also makes sure that we actually renumber regions in the length of repeat exprs which we previously weren't doing and would cause ICEs in `adt_const_params` + `generic_const_exprs` from attempting to prove the wf goals when the length was an unevaluated constant with `'erased` in the `ty` field of `Const` The duplicate errors are caused by the fact that `const_arg_to_const`/`array_len_to_const` in `FnCtxt` adds a `WellFormed` goal for the created `Const` which is also checked by the added `WellFormed(array_ty)`. I don't want to change this to just emit a `T: Sized` goal for the element type since that would ignore `ConstArgHasType` wf requirements and generally uncomfortable with the idea of trying to sync up `wf::obligations` for arrays and the code in hir typeck for repeat exprs. r? `@compiler-errors`
2023-05-04do not allow rustc::pass_by_value lintBoxy-6/+4
2023-05-04check array type of repeat exprs is wfBoxy-2/+21
2023-04-29Expand comment on NonMutatingUseContext.Camille GILLOT-0/+3
2023-04-29Make PlaceMention a non-mutating use.Camille GILLOT-3/+3
2023-04-11Preserve argument indexes when inlining MIRDavid Lattimore-0/+1
We store argument indexes on VarDebugInfo. Unlike the previous method of relying on the variable index to know whether a variable is an argument, this survives MIR inlining. We also no longer check if var.source_info.scope is the outermost scope. When a function gets inlined, the arguments to the inner function will no longer be in the outermost scope. What we care about though is whether they were in the outermost scope prior to inlining, which we know by whether we assigned an argument index.
2023-04-06Rename `Abort` terminator to `Terminate`Gary Guo-1/+1
Unify terminology used in unwind action and terminator, and reflect the fact that a nounwind panic is triggered instead of an immediate abort is triggered for this terminator.
2023-04-06Refactor unwind from Option to a new enumGary Guo-3/+3
2023-03-31Auto merge of #98112 - saethlin:mir-alignment-checks, r=oli-obkbors-0/+4
Insert alignment checks for pointer dereferences when debug assertions are enabled Closes https://github.com/rust-lang/rust/issues/54915 - [x] Jake tells me this sounds like a place to use `MirPatch`, but I can't figure out how to insert a new basic block with a new terminator in the middle of an existing basic block, using `MirPatch`. (if nobody else backs up this point I'm checking this as "not actually a good idea" because the code looks pretty clean to me after rearranging it a bit) - [x] Using `CastKind::PointerExposeAddress` is definitely wrong, we don't want to expose. Calling a function to get the pointer address seems quite excessive. ~I'll see if I can add a new `CastKind`.~ `CastKind::Transmute` to the rescue! - [x] Implement a more helpful panic message like slice bounds checking. r? `@oli-obk`
2023-03-29Support TLS access into dylibs on WindowsJohn Kåre Alsaker-0/+1
2023-03-27Add a builtin `FnPtr` traitlcnr-1/+2
2023-03-23A MIR transform that checks pointers are alignedBen Kimock-0/+4
2023-03-14Make is_block_tail a variant of LocalInfo.Camille GILLOT-1/+0
2023-03-09Introduce a no-op PlaceMention statement for `let _ =`.Camille GILLOT-0/+9
2023-03-07Remove DropAndReplace terminatorGiacomo Pasini-14/+0
PR 107844 made DropAndReplace unused, let's remove it completely from the codebase.
2023-02-24Rename many interner functions.Nicholas Nethercote-1/+1
(This is a large commit. The changes to `compiler/rustc_middle/src/ty/context.rs` are the most important ones.) The current naming scheme is a mess, with a mix of `_intern_`, `intern_` and `mk_` prefixes, with little consistency. In particular, in many cases it's easy to use an iterator interner when a (preferable) slice interner is available. The guiding principles of the new naming system: - No `_intern_` prefixes. - The `intern_` prefix is for internal operations. - The `mk_` prefix is for external operations. - For cases where there is a slice interner and an iterator interner, the former is `mk_foo` and the latter is `mk_foo_from_iter`. Also, `slice_interners!` and `direct_interners!` can now be `pub` or non-`pub`, which helps enforce the internal/external operations division. It's not perfect, but I think it's a clear improvement. The following lists show everything that was renamed. slice_interners - const_list - mk_const_list -> mk_const_list_from_iter - intern_const_list -> mk_const_list - substs - mk_substs -> mk_substs_from_iter - intern_substs -> mk_substs - check_substs -> check_and_mk_substs (this is a weird one) - canonical_var_infos - intern_canonical_var_infos -> mk_canonical_var_infos - poly_existential_predicates - mk_poly_existential_predicates -> mk_poly_existential_predicates_from_iter - intern_poly_existential_predicates -> mk_poly_existential_predicates - _intern_poly_existential_predicates -> intern_poly_existential_predicates - predicates - mk_predicates -> mk_predicates_from_iter - intern_predicates -> mk_predicates - _intern_predicates -> intern_predicates - projs - intern_projs -> mk_projs - place_elems - mk_place_elems -> mk_place_elems_from_iter - intern_place_elems -> mk_place_elems - bound_variable_kinds - mk_bound_variable_kinds -> mk_bound_variable_kinds_from_iter - intern_bound_variable_kinds -> mk_bound_variable_kinds direct_interners - region - intern_region (unchanged) - const - mk_const_internal -> intern_const - const_allocation - intern_const_alloc -> mk_const_alloc - layout - intern_layout -> mk_layout - adt_def - intern_adt_def -> mk_adt_def_from_data (unusual case, hard to avoid) - alloc_adt_def(!) -> mk_adt_def - external_constraints - intern_external_constraints -> mk_external_constraints Other - type_list - mk_type_list -> mk_type_list_from_iter - intern_type_list -> mk_type_list - tup - mk_tup -> mk_tup_from_iter - intern_tup -> mk_tup
2023-02-19collect region contexts during mir renumberingb-naber-1/+1
2023-02-16`BasicBlock::new(0)` -> `START_BLOCK` [no functional changes]Scott McMurray-3/+3
2023-01-23Create stable metric to measure long computation in Const EvalBryan Garza-0/+1
This patch adds a `MirPass` that tracks the number of back-edges and function calls in the CFG, adds a new MIR instruction to increment a counter every time they are encountered during Const Eval, and emit a warning if a configured limit is breached.
2022-12-16accept review suggestionTshepang Mbambo-1/+1
Co-authored-by: nils <48135649+Nilstrieb@users.noreply.github.com>
2022-12-14some fixes/improvements to mir::visit moduleTshepang Mbambo-4/+4
2022-12-09Remove unneeded field from `SwitchTargets`Jakob Degen-2/+0
2022-11-15Introduce composite debuginfo.Camille GILLOT-0/+11
2022-11-07Only assume Stacked Borrows if -Zunsound-mir-opts is givenJannis Christopher Köhl-0/+9
2022-09-20Auto merge of #99806 - oli-obk:unconstrained_opaque_type, r=estebankbors-1/+6
Allow patterns to constrain the hidden type of opaque types fixes #96572 reverts a revert as original PR was a perf regression that was fixed by reverting it: https://github.com/rust-lang/rust/pull/99368#issuecomment-1186587864) TODO: * check if https://github.com/rust-lang/rust/issues/99685 is avoided