about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-03-16Auto merge of #109183 - lqd:revert-107376, r=compiler-errorsbors-29/+152
Revert #107376 to fix potential `bincode` breakage and `rustc-perf` benchmark. #107376 caused `rustc-perf`'s `webrender` benchmark to break, by regressing on the `bincode-1.3.3` crate. ~~This PR is a draft revert in case we can't land a fix soon enough, and we'd like to land the revert instead~~ (Though I myself think it'd be safer to do the revert, and run crater when relanding #107376.) cc `@aliemjay`
2023-03-15Auto merge of #108282 - cjgillot:mir-checked-sh, r=tmiaskobors-81/+75
Implement checked Shl/Shr at MIR building. This does not require any special handling by codegen backends, as the overflow behaviour is entirely determined by the rhs (shift amount). This allows MIR ConstProp to remove the overflow check for constant shifts. ~There is an existing different behaviour between cg_llvm and cg_clif (cc `@bjorn3).` I took cg_llvm's one as reference: overflow if `rhs < 0 || rhs > number_of_bits_in_lhs_ty`.~ EDIT: `cg_llvm` and `cg_clif` implement the overflow check differently. This PR uses `cg_llvm`'s implementation based on a `BitAnd` instead of `cg_clif`'s one based on an unsigned comparison.
2023-03-15Auto merge of #109169 - bjorn3:sync_cg_clif-2023-03-15, r=bjorn3bors-792/+873
Sync rustc_codegen_cranelift Bunch of bug fixes this time. Also an update to Cranelift 0.93 which adds a brand new optimization pass which cg_clif exposes when using `--release`. And various improvements to cg_clif's test suite, making it faster to run. And finally two small perf improvements. r? `@ghost` `@rustbot` label +A-codegen +A-cranelift +T-compiler
2023-03-15Revert "Auto merge of #107376 - aliemjay:remove-givens, r=lcnr"Rémy Rakic-29/+152
This reverts commit e84e5ff04a647ce28540300244a26ba120642eea, reversing changes made to 1716932743a7b3705cbf0c34db0c4e070ed1930d.
2023-03-15Auto merge of #109164 - Dylan-DPC:rollup-0bwxwos, r=Dylan-DPCbors-160/+114
Rollup of 7 pull requests Successful merges: - #108991 (add `enable-warnings` flag for llvm, and disable it by default.) - #109109 (Use `unused_generic_params` from crate metadata) - #109111 (Create dirs for build_triple) - #109136 (Simplify proc macro signature validity check) - #109150 (Update cargo) - #109154 (Fix MappingToUnit to support no span of arg_ty) - #109157 (Remove mw from review rotation for a while) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-15Merge commit 'dec0daa8f6d0a0e1c702f169abb6bf3eee198c67' into ↵bjorn3-792/+873
sync_cg_clif-2023-03-15
2023-03-15Rollup merge of #109154 - chenyukang:yukang/fix-109152, r=compiler-errorsDylan DPC-2/+9
Fix MappingToUnit to support no span of arg_ty Fixes #109152
2023-03-15Rollup merge of #109136 - compiler-errors:simplify-proc-macro-checking, ↵Dylan DPC-148/+92
r=oli-obk Simplify proc macro signature validity check Use an `ObligationCtxt` instead of `normalize_erasing_regions` + `DeepRejectCtxt`. This should both give us a more accurate error message, and also avoid issues like not-well-formed proc macro signatures. Also, let's fall back on the regular type mismatch error reporting for making these diagnostic notes, instead of hard-coding a bunch of specific diagnostics. Fixes #109129
2023-03-15Rollup merge of #109109 - compiler-errors:polymorphize-foreign, r=NilstriebDylan DPC-10/+13
Use `unused_generic_params` from crate metadata Due to the way that `separate_provide_extern` interacted with the implementation of `<ty::InstanceDef<'tcx> as Key>::query_crate_is_local`, we actually never hit the foreign provider for `unused_generic_params`. Additionally, since the *local* provider of `unused_generic_params` calls `should_polymorphize`, which always returns false if the def-id is foreign, this means that we never actually polymorphize monomorphic instances originating from foreign crates. We don't actually encode `unused_generic_params` for items where all generics are used, so I had to tweak the foreign provider to fall back to `ty::UnusedGenericParams::new_all_used()` to avoid more ICEs when the above bugs were fixed.
2023-03-15Auto merge of #109035 - scottmcm:ptr-read-should-know-undef, ↵bors-3/+36
r=WaffleLapkin,JakobDegen Ensure `ptr::read` gets all the same LLVM `load` metadata that dereferencing does I was looking into `array::IntoIter` optimization, and noticed that it wasn't annotating the loads with `noundef` for simple things like `array::IntoIter<i32, N>`. Trying to narrow it down, it seems that was because `MaybeUninit::assume_init_read` isn't marking the load as initialized (<https://rust.godbolt.org/z/Mxd8TPTnv>), which is unfortunate since that's basically its reason to exist. The root cause is that `ptr::read` is currently implemented via the *untyped* `copy_nonoverlapping`, and thus the `load` doesn't get any type-aware metadata: no `noundef`, no `!range`. This PR solves that by lowering `ptr::read(p)` to `copy *p` in MIR, for which the backends already do the right thing. Fortuitiously, this also improves the IR we give to LLVM for things like `mem::replace`, and fixes a couple of long-standing bugs where `ptr::read` on `Copy` types was worse than `*`ing them. Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Move.20array.3A.3AIntoIter.20to.20ManuallyDrop/near/341189936> cc `@erikdesjardins` `@JakobDegen` `@workingjubilee` `@the8472` Fixes #106369 Fixes #73258
2023-03-15Auto merge of #109089 - compiler-errors:opt_rpitit_info-follow-up, r=spastorinobors-8/+16
Encode `opt_rpitit_info` for associated types Follow-up, only last commit matters r? `@spastorino` This needs a perf run after the parent pr lands
2023-03-15Fix #109152, fix the scenario that we may can not get span of funcyukang-2/+9
2023-03-14Improved implementation and comments after code review feedbackScott McMurray-13/+18
2023-03-15Auto merge of #107376 - aliemjay:remove-givens, r=lcnrbors-152/+29
remove obsolete `givens` from regionck Fixes #106567 r? `@lcnr` (feel free to reassign)
2023-03-14Encode opt_rpitit_info for associated typesMichael Goulet-8/+16
2023-03-14Tighter spansMichael Goulet-2/+35
2023-03-14Simplify proc macro signature validity checkMichael Goulet-151/+62
2023-03-14Auto merge of #109130 - matthiaskrgr:rollup-dm3jza6, r=matthiaskrgrbors-43/+140
Rollup of 9 pull requests Successful merges: - #108722 (Support for Fuchsia RISC-V target) - #108880 (Remove tests/ui/impl-trait/in-trait/new-lowering-strategy in favor of using revisions on existing tests) - #108909 (Fix object safety checks for new RPITITs) - #108915 (Remove some direct calls to local_def_id_to_hir_id on diagnostics) - #108923 (Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty) - #109101 (Fall back to old metadata computation when type references errors) - #109105 (Don't ICE for late-bound consts across `AnonConstBoundary`) - #109110 (Don't codegen impossible to satisfy impls) - #109116 (Emit diagnostic when calling methods on the unit type in method chains) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2023-03-14Rollup merge of #109116 - ↵Matthias Krüger-26/+64
MaciejWas:add-modifies-receiver-diagn-when-method-not-found, r=petrochenkov Emit diagnostic when calling methods on the unit type in method chains Fixes #104204. What this PR does: If a method is not found somewhere in a call chain, we check if we called earlier a method with signature `(&mut T, ...) -> ()`. If this is the case then we emit a diagnostic message. For example given input: ``` vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); ``` the current output is: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` ``` after this PR it will be: ``` error[E0599]: no method named `sort` found for unit type `()` in the current scope --> ./hello.rs:3:72 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^ method not found in `()` | note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. --> ./hello.rs:3:53 | 3 | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); | ^^^^^^^^^^^ this call modifies its receiver in-place ```
2023-03-14Rollup merge of #109110 - compiler-errors:impossible-impl-mono, r=jackh726Matthias Krüger-0/+15
Don't codegen impossible to satisfy impls Fixes #109098
2023-03-14Rollup merge of #109105 - compiler-errors:late-ct-in-anon-ct, r=oli-obkMatthias Krüger-7/+7
Don't ICE for late-bound consts across `AnonConstBoundary` Fixes #108194
2023-03-14Rollup merge of #109101 - compiler-errors:layout-err, r=michaelwoeristerMatthias Krüger-2/+10
Fall back to old metadata computation when type references errors Projection is a bit too aggressive normalizing `<dyn Trait<[type error]> as Pointee>::Metadata` to `[type error]`, rather than to `DynMetadata<..>`. Side-step that by just falling back to the old structural metadata computation. Fixes #109078
2023-03-14Rollup merge of #108923 - spastorino:new-rpitit-9, r=compiler-errorsMatthias Krüger-3/+14
Make fns from other crates with RPITIT work for -Zlower-impl-trait-in-trait-to-assoc-ty Only the last two commits are meaningful. r? `@compiler-errors`
2023-03-14Rollup merge of #108915 - spastorino:new-rpitit-8, r=compiler-errorsMatthias Krüger-2/+6
Remove some direct calls to local_def_id_to_hir_id on diagnostics Was playing with `tests/ui/impl-trait/in-trait/default-body-with-rpit.rs` and was able to remove some ICEs. Still getting ... ``` error[E0277]: `impl Future<Output = Foo::{opaque#0}>` is not a future --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ `impl Future<Output = Foo::{opaque#0}>` is not a future | = help: the trait `Future` is not implemented for `impl Future<Output = Foo::{opaque#0}>` = note: impl Future<Output = Foo::{opaque#0}> must be a future or must implement `IntoFuture` to be awaited note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error[E0277]: the size for values of type `impl Future<Output = Foo::{opaque#0}>` cannot be known at compilation time --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `impl Future<Output = Foo::{opaque#0}>` note: required by a bound in `Foo::{opaque#1}` --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:28 | 10 | async fn baz(&self) -> impl Debug { | ^^^^^^^^^^ required by this bound in `Foo::{opaque#1}` error: internal compiler error: compiler/rustc_hir_typeck/src/closure.rs:724:18: async fn generator return type not an inference variable: Foo::{opaque#1}<'_> --> tests/ui/impl-trait/in-trait/default-body-with-rpit.rs:10:39 | 10 | async fn baz(&self) -> impl Debug { | _______________________________________^ 11 | | "" 12 | | } | |_____^ ``` But I guess this is a little bit of progress anyway. This one goes on top of #108700 and #108945 r? `@compiler-errors`
2023-03-14Rollup merge of #108909 - spastorino:new-rpitit-7, r=compiler-errorsMatthias Krüger-3/+4
Fix object safety checks for new RPITITs This one goes on top of #108869 r? `@compiler-errors`
2023-03-14Rollup merge of #108722 - petrhosek:fuchsia-riscv, r=petrochenkovMatthias Krüger-0/+20
Support for Fuchsia RISC-V target Fuchsia is in the process of implementing the RISC-V support. This change implements the minimal Rust compiler support. The support for building runtime libraries will be implemented in follow up changes once Fuchsia SDK has the RISC-V support.
2023-03-14Use `unused_generic_params` from crate metadataMichael Goulet-10/+13
2023-03-14Don't codegen impossible to satisfy implsMichael Goulet-0/+15
2023-03-14Emit "modifies receiver" diagnostic when no method is foundMaciej Wasilewski-26/+64
If no method is found when checking method call, we check if we called a method with signature (&mut T, ...) -> (). If this is the case then we emit a diagnostic message
2023-03-14Remove some direct calls to local_def_id_to_hir_id on diagnosticsSantiago Pastorino-2/+6
2023-03-14Auto merge of #106505 - Nilstrieb:format-args-string-literal-episode-2, ↵bors-44/+89
r=petrochenkov Properly allow macro expanded `format_args` invocations to uses captures Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see #106191). So I tightened it up in #106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. Fixes #106191 [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Improve heuristics for format_args literal being suggestableNilstrieb-1/+35
Sometimes, we want to create subspans and point at code in the literal if possible. But this doesn't always make sense, sometimes the literal may come from macro expanded code and isn't actually there in the source. Then, we can't really make these suggestions. This now makes sure that the literal is actually there as we see it so that we will not run into ICEs on weird literal transformations.
2023-03-14Make fns from other crates with RPITIT workSantiago Pastorino-1/+11
2023-03-14Properly allow macro expanded `format_args` invocations to uses capturesNilstrieb-43/+54
Originally, this was kinda half-allowed. There were some primitive checks in place that looked at the span to see whether the input was likely a literal. These "source literal" checks are needed because the spans created during `format_args` parsing only make sense when it is indeed a literal that was written in the source code directly. This is orthogonal to the restriction that the first argument must be a "direct literal", not being exanpanded from macros. This restriction was imposed by [RFC 2795] on the basis of being too confusing. But this was only concerned with the argument of the invocation being a literal, not whether it was a source literal (maybe in spirit it meant it being a source literal, this is not clear to me). Since the original check only really cared about source literals (which is good enough to deny the `format_args!(concat!())` example), macros expanding to `format_args` invocations were able to use implicit captures if they spanned the string in a way that lead back to a source string. The "source literal" checks were not strict enough and caused ICEs in certain cases (see # 106191 (the space is intended to avoid spammy backreferences)). So I tightened it up in # 106195 to really only work if it's a direct source literal. This caused the `indoc` crate to break. `indoc` transformed the source literal by removing whitespace, which made it not a "source literal" anymore (which is required to fix the ICE). But since `indoc` spanned the literal in ways that made the old check think that it's a literal, it was able to use implicit captures (which is useful and nice for the users of `indoc`). This commit properly seperates the previously introduced concepts of "source literal" and "direct literal" and therefore allows `indoc` invocations, which don't create "source literals" to use implicit captures again. [RFC 2795]: https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html#macro-hygiene
2023-03-14Get impl defaultness using querySantiago Pastorino-2/+3
2023-03-14Auto merge of #104833 - Swatinem:async-identity-future, r=compiler-errorsbors-56/+32
Remove `identity_future` indirection This was previously needed because the indirection used to hide some unexplained lifetime errors, which it turned out were related to the `min_choice` algorithm. Removing the indirection also solves a couple of cycle errors, large moves and makes async blocks support the `#[track_caller]`annotation. Fixes https://github.com/rust-lang/rust/issues/104826.
2023-03-14Auto merge of #109057 - compiler-errors:rpitit-info-again, r=spastorinobors-23/+31
Don't `opt_rpitit_info` as a separate query ... another attempt to undo regressions r? `@ghost`
2023-03-14Auto merge of #108992 - petrochenkov:qcstore2, r=cjgillotbors-246/+165
resolve: Querify most cstore access methods (subset) A subset of https://github.com/rust-lang/rust/pull/108346 that is not on a hot path in any way.
2023-03-13Don't ICE for late-bound consts across AnonConstBoundaryMichael Goulet-7/+7
2023-03-13Layout of `&dyn Trait<[type error]>` is still wideMichael Goulet-2/+10
2023-03-13Rollup merge of #109088 - Nilstrieb:target-feature-on-statics-when, ↵Matthias Krüger-20/+25
r=compiler-errors Gracefully handle `#[target_feature]` on statics The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds. I was sadly not able to fully bless the test locally because I'm on an aarch64 machine but I hope some manual editing made it work 😅 Fix #109079
2023-03-13Rollup merge of #109058 - tmiasko:is-checkable, r=jackh726Matthias Krüger-0/+3
Document BinOp::is_checkable
2023-03-13Gracefully handle `#[target_feature]` on staticsNilstrieb-20/+25
The was careful around not calling `fn_sig` on not-functions but well, it wasn't careful enough. This commit makes it a little more careful and also adds tests for a bunch more item kinds.
2023-03-13Don't opt_rpitit_info as a separate queryMichael Goulet-23/+31
2023-03-13Better names?Michael Goulet-48/+54
2023-03-13Treat projections with infer as placeholder during fast reject in new solverMichael Goulet-66/+160
2023-03-13metadata/resolve: Minor refactoring to "tcx -> cstore" conversionsVadim Petrochenkov-9/+14
2023-03-13metadata: Remove some more untracked `CStore` methodsVadim Petrochenkov-21/+10
2023-03-13resolve: Remove `struct_field_names_untracked`Vadim Petrochenkov-72/+52
2023-03-13resolve: Centralize retrieval of items span and item nameVadim Petrochenkov-69/+37