about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-04-17Rollup merge of #110257 - ↵Matthias Krüger-18/+32
lukas-code:why-would-anyone-write-code-like-that-anyway, r=oli-obk fix false positives for `unused_parens` around unary and binary operations fix https://github.com/rust-lang/rust/issues/110251
2023-04-17Rollup merge of #104055 - AndyJado:bck_errors, r=davidtwcoMatthias Krüger-252/+612
Migrate diagnostics in `rustc_borrowck` sorry for making a new PR, [#103559](https://github.com/rust-lang/rust/pull/103559) and [#103960](https://github.com/rust-lang/rust/pull/103960). I am crawling, joyfully.
2023-04-17Auto merge of #110367 - saethlin:no-truncations, r=oli-obkbors-33/+9
Remove some suspicious cast truncations These truncations were added a long time ago, and as best I can tell without a perf justification. And with rust-lang/rust#110410 it has become perf-neutral to not truncate anymore. We worked hard for all these bits, let's use them.
2023-04-17Auto merge of #110440 - matthiaskrgr:rollup-eit19vi, r=matthiaskrgrbors-107/+79
Rollup of 7 pull requests Successful merges: - #110038 (Erase regions when confirming transmutability candidate) - #110341 (rustdoc: stop passing a title to `replaceState` second argument) - #110388 (Add a message for if an overflow occurs in `core::intrinsics::is_nonoverlapping`.) - #110404 (fix clippy::toplevel_ref_arg and ::manual_map) - #110421 (Spelling librustdoc) - #110423 (Spelling srcdoc) - #110433 (Windows: map a few more error codes to ErrorKind) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-17Rollup merge of #110404 - matthiaskrgr:mapmap, r=NilstriebMatthias Krüger-66/+39
fix clippy::toplevel_ref_arg and ::manual_map r? ``@Nilstrieb``
2023-04-17Rollup merge of #110038 - compiler-errors:infer-regions-in-transmutability, ↵Matthias Krüger-41/+40
r=lcnr Erase regions when confirming transmutability candidate Fixes an ICE where we call `layout_of` on a type with infer regions.
2023-04-17Auto merge of #109588 - Nilstrieb:dropless-expr, r=compiler-errorsbors-33/+29
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.
2023-04-17Auto merge of #109247 - saethlin:inline-without-inline, r=oli-obkbors-8/+2
Permit MIR inlining without #[inline] I noticed that there are at least a handful of portable-simd functions that have no `#[inline]` but compile to an assign + return. I locally benchmarked inlining thresholds between 0 and 50 in increments of 5, and 50 seems to be the best. Interesting. That didn't include check builds though, ~maybe perf will have something to say about that~. Perf has little useful to say about this. We generally regress all the check builds, as best as I can tell, due to a number of small codegen changes in a particular hot function in the compiler. Probably this is because we've nudged the inlining outcomes all over, and uses of `#[inline(always)]`/`#[inline(never)]` might need to be adjusted.
2023-04-17Auto merge of #109061 - saethlin:leak-backtraces, r=oli-obkbors-18/+18
Add a backtrace to Allocation, display it in leak reports This addresses https://github.com/rust-lang/miri/issues/2813 Information like this from diagnostics is indispensable for diagnosing problems that are difficult to reproduce such as https://github.com/rust-lang/miri-test-libstd/actions/runs/4395316008/jobs/7697019211#step:4:770 (which has not been reproduced or diagnosed).
2023-04-16Remove some unnecessary hash truncationsBen Kimock-33/+9
2023-04-16Erase regions when confirming transmutability candidateMichael Goulet-41/+40
2023-04-16Alloc `hir::Lit` in an arena to remove the destructor from `Expr`Nilstrieb-33/+29
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.
2023-04-16Auto merge of #110405 - fee1-dead-contrib:rollup-9rkree6, r=fee1-deadbors-112/+90
Rollup of 4 pull requests Successful merges: - #110397 (Move some utils out of `rustc_const_eval`) - #110398 (use matches! macro in more places) - #110400 (more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_defau…) - #110402 (Remove the loop in `Align::from_bytes`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-04-16Report a backtrace for memory leaks under MiriBen Kimock-18/+18
2023-04-16Rollup merge of #110402 - scottmcm:align-tz, r=fee1-deadfee1-dead-7/+4
Remove the loop in `Align::from_bytes` Perf is almost certainly irrelevant, but might as well simplify it, since `trailing_zeros` does exactly what's needed.
2023-04-16Rollup merge of #110400 - matthiaskrgr:style_mix, r=fee1-deadfee1-dead-6/+4
more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_defau… …lt, option_map_or_none} r? `@Nilstrieb`
2023-04-16Rollup merge of #110398 - matthiaskrgr:clippy_match, r=Nilstrieb,fee1-deadfee1-dead-75/+52
use matches! macro in more places r? `@Nilstrieb`
2023-04-16fix clippy::toplevel_ref_arg and ::manual_mapMatthias Krüger-66/+39
2023-04-16Remove the loop in `Align::from_bytes`Scott McMurray-7/+4
Perf is almost certainly irrelevant, but might as well simplify it, since `trailing_zeros` does exactly what's needed.
2023-04-16Rollup merge of #110396 - Nilstrieb:speedy-bootstrap, r=jyn514fee1-dead-2/+2
Use lint via `lint_defs` instead of `lints` This gets rid of a blocking dependency edge from `rustc_lint->rustc_analysis->rustc_hir_typeck->rustc_interface` ![image](https://user-images.githubusercontent.com/48135649/232291152-fc61e6c5-9b1e-4db1-8101-dfaa3b7d30c6.png)
2023-04-16Rollup merge of #110345 - nnethercote:rm-Super-impls-for-Region, ↵fee1-dead-60/+46
r=compiler-errors Remove `TypeSuper{Foldable,Visitable}` impls for `Region`. These traits exist so that folders/visitors can recurse into types of interest: binders, types, regions, predicates, and consts. But `Region` is non-recursive and cannot contain other types of interest, so its methods in these traits are trivial. This commit inlines and removes those trivial methods. r? `@compiler-errors`
2023-04-16Rollup merge of #109665 - fee1-dead-contrib:rm-remap-queries, r=oli-obkfee1-dead-68/+2
Remove `remap_env_constness` in queries This removes some of the complexities with const traits. #88119 used to be caused by this but was fixed by `param_env = param_env.without_const()`.
2023-04-16more clippy fixes: clippy::{iter_cloned_collect, unwarp_or_else_default, ↵Matthias Krüger-6/+4
option_map_or_none}
2023-04-16use matches! macro in more placesMatthias Krüger-75/+52
2023-04-16Move some utils out of `rustc_const_eval`Nilstrieb-24/+30
This allows us to get rid of the `rustc_const_eval->rustc_borrowck` dependency edge which was delaying the compilation of borrowck. The added utils in `rustc_middle` are small and should not affect compile times there.
2023-04-16Use lints via `lint_defs` instead of `lints`Nilstrieb-2/+2
This gets rid of a blocking dependency edge from `rustc_lint->rustc_analysis->rustc_hir_typeck->rustc_interface`
2023-04-16Rollup merge of #110387 - nnethercote:rm-use-rustc_hir-as-ast, r=fee1-deadfee1-dead-7/+7
Don't `use rustc_hir as ast`(!) It makes for confusing code. This was introduced in a large commit in #67886 that rearranged a lot of `use` statements. I suspect it was an accident.
2023-04-16Rollup merge of #110376 - aDotInTheVoid:doc-comment, r=jyn514fee1-dead-2/+3
Convert comment to doc comment on `Interner::get`.
2023-04-16Don't `use rustc_hir as ast`(!)Nicholas Nethercote-7/+7
It makes for confusing code. This was introduced in a large commit in #67886 that rearranged a lot of `use` statements. I suspect it was an accident.
2023-04-16Auto merge of #105888 - skyzh:skyzh/suggest-lifetime-closure, r=compiler-errorsbors-2/+79
suggest lifetime for closure parameter type when mismatch This is a draft PR, will add test cases later and be ready for review. This PR fixes https://github.com/rust-lang/rust/issues/105675 by adding a diagnostics suggestion. Also a partial fix to https://github.com/rust-lang/rust/issues/105528. The following code will have a compile error now: ``` fn const_if_unit(input: bool) -> impl for<'a> FnOnce(&'a ()) -> usize { let x = |_| 1; x } ``` Before this PR: ``` error[E0308]: mismatched types --> src/lib.rs:3:5 | 3 | x | ^ one type is more general than the other | = note: expected trait `for<'a> FnOnce<(&'a (),)>` found trait `FnOnce<(&(),)>` note: this closure does not fulfill the lifetime requirements --> src/lib.rs:2:13 | 2 | let x = |_| 1; | ^^^ error: implementation of `FnOnce` is not general enough --> src/lib.rs:3:5 | 3 | x | ^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 ()) -> usize` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` For more information about this error, try `rustc --explain E0308`. error: could not compile `rust-test` due to 2 previous errors ``` After this PR: ``` error[E0308]: mismatched types --> src/lib.rs:3:5 | 3 | x | ^ one type is more general than the other | = note: expected trait `for<'a> FnOnce<(&'a (),)>` found trait `FnOnce<(&(),)>` note: this closure does not fulfill the lifetime requirements --> src/lib.rs:2:13 | 2 | let x = |_| 1; | ^^^ help: consider changing the type of the closure parameters | 2 | let x = |_: &_| 1; | ~~~~~~~ error: implementation of `FnOnce` is not general enough --> src/lib.rs:3:5 | 3 | x | ^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 ()) -> usize` must implement `FnOnce<(&'1 (),)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 (),)>`, for some specific lifetime `'2` For more information about this error, try `rustc --explain E0308`. error: could not compile `rust-test` due to 2 previous errors ``` After applying the suggestion, it compiles. The suggestion might not always be correct as the generation procedure of that suggestion is quite simple...
2023-04-16Remove `TypeSuper{Foldable,Visitable}` impls for `Region`.Nicholas Nethercote-60/+46
These traits exist so that folders/visitors can recurse into types of interest: binders, types, regions, predicates, and consts. But `Region` is non-recursive and cannot contain other types of interest, so its methods in these traits are trivial. This commit inlines and removes those trivial methods.
2023-04-16Rollup merge of #110366 - matthiaskrgr:compl_123, r=NilstriebYuki Okushi-23/+18
fix some clippy::complexity r? `@Nilstrieb`
2023-04-16Rollup merge of #110364 - matthiaskrgr:anti_clone, r=NilstriebYuki Okushi-11/+12
remove redundant clones
2023-04-16Rollup merge of #110272 - Ezrashaw:fix-unconned-lt-in-implbounds, r=aliemjayYuki Okushi-1/+12
fix: skip implied bounds if unconstrained lifetime exists Fixes #110161 r? ````@aliemjay````
2023-04-15Convert comment to doc comment on `Interner::get`.Alona Enraght-Moony-2/+3
2023-04-15fix clippy::{clone_on_copy, useless_conversion}Matthias Krüger-5/+4
2023-04-15fix clippy::{filter_map_identiy, map_identity, manual_flatten}Matthias Krüger-18/+14
2023-04-15remove redundant clonesMatthias Krüger-11/+12
2023-04-15Update compiler/rustc_trait_selection/src/traits/outlives_bounds.rsAli MJ Al-Nasrawy-2/+3
2023-04-15Auto merge of #110323 - lcnr:dropck-uwu, r=compiler-errorsbors-1/+3
explicit `adt_dtorck_constraint` for `ManuallyDrop` the only reason we didn't add outlives requirements when dropping `ManuallyDrop` was a fast-path in `trivial_dropck_outlives`. Explicitly acknowledge that fast-path in `adt_dtorck_constraint`
2023-04-15Remove outdated comment.Camille GILLOT-2/+0
2023-04-15Remove useless methods in visit.Camille GILLOT-6/+0
2023-04-15Only enable ConstProp at mir-opt-level >= 2.Camille GILLOT-1/+1
2023-04-14Auto merge of #110197 - cjgillot:codegen-discr, r=pnkfelixbors-181/+0
Do not attempt to commute comparison and cast to codegen discriminants The general algorithm to compute a discriminant is: ``` relative_tag = tag - niche_start is_niche = relative_tag <= (ule) relative_max discr = if is_niche { cast(relative_tag) + niche_variants.start() } else { untagged_variant } ``` We have an optimization branch which attempts to merge the addition and the subtraction by commuting them with the cast. We currently get this optimization wrong. This PR takes the easiest and safest way: remove the optimization, and let LLVM handle it. (Perf may not agree with that course of action :sweat_smile:) There may be a less invasive solution, but I don't have the necessary knowledge of LLVM semantics to find it. Cranelift has the same optimization, which should be handled similarly. cc `@nikic` and `@bjorn3` if you have a better solution. Fixes https://github.com/rust-lang/rust/issues/110128
2023-04-14Rollup merge of #108687 - ↵Matthias Krüger-200/+230
compiler-errors:reformulate-point_at_expr_source_of_inferred_type, r=oli-obk Reformulate `point_at_expr_source_of_inferred_type` to be more accurate Be more accurate when deducing where along the several usages of a binding it is constrained to be some type that is incompatible with an expectation. This also renames the method to `note_source_of_type_mismatch_constraint` because I prefer that name, though I guess I can revert that. (Also drive-by rename `note_result_coercion` -> `suggest_coercing_result_via_try_operator`, because it's suggesting, not noting!) This PR is (probably?) best reviewed per commit, but it does regress a bit only to fix it later on, so it could also be reviewed as a whole if that makes the final results more clear. r? `@estebank`
2023-04-14Remove from cranelift too.Camille GILLOT-89/+0
2023-04-14Remove attempt to optimize codegen for discriminants.Camille GILLOT-92/+0
2023-04-14fix import ApplicabilityAlex Chi-1/+1
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14use param instead of tyAlex Chi-5/+17
Signed-off-by: Alex Chi <iskyzh@gmail.com>
2023-04-14better suggestion based on hirAlex Chi-41/+49
Signed-off-by: Alex Chi <iskyzh@gmail.com>