about summary refs log tree commit diff
path: root/compiler
AgeCommit message (Collapse)AuthorLines
2023-05-23Rollup merge of #111486 - fmease:pp-inh-proj, r=petrochenkovMatthias Krüger-4/+28
Pretty-print inherent projections correctly Previously, we were trying to pretty-print inherent projections with `Printer::print_def_path` which is incorrect since it expects the substitutions to be of a certain format (parents substs followed by own substs) which doesn't hold for inherent projections (self type subst followed by own substs). Now we print inherent projections manually. Fixes #111390. Fixes #111397. Lacking tests! Is there a test suite / compiletest flags for the pretty-printer? In most if not all cases, inherent projections are normalized away before they get the chance to appear in diagnostics. If I were to create regression tests for linked issues, they would need to be `mir-opt` tests to exercise `-Zdump-mir=all` (right?) which doesn't feel quite adequate to me. `@rustbot` label F-inherent_associated_types
2023-05-23Don't ICE when computing PointerLike trait when region vars are in param-envMichael Goulet-10/+16
2023-05-23Always require closure parameters to be `Sized`Jules Bertholet-2/+5
The `rust-call` ABI isn't compatible with `#![feature(unsized_fn_params)]`, so trying to use that feature with closures leads to an ICE (#67981). This turns that ICE into a type-check error.
2023-05-23CFI: Fix encode_region: unexpected ReEarlyBound(0, 'a)Ramon de C Valle-7/+7
Fixes #111515 and complements #106547 by adding support for encoding early bound regions and also excluding projections when transforming trait objects' traits into their identities before emitting type checks.
2023-05-23Add RegionInferenceContext::outlives_constraintsDominik Stolz-1/+7
2023-05-23Auto merge of #107294 - JamieCunliffe:neon-fp, r=Amanieubors-38/+129
Fix some issues with folded AArch64 features In #91608 the `fp` feature was removed for AArch64 and folded into the `neon` feature, however disabling the `neon` feature doesn't actually disable the `fp` feature. If my understanding on that thread is correct it should do. While doing this, I also noticed that disabling some features would disable features that it shouldn't. For instance enabling `sve` will enable `neon`, however, when disabling `sve` it would then also disable `neon`, I wouldn't expect disabling `sve` to also disable `neon`. cc `@workingjubilee`
2023-05-23Don't leak the function that is called on dropMaybe Waffle-15/+21
2023-05-23Ignore "non-real" type Res in rustdoc intra doc link resolutionGuillaume Gomez-7/+8
2023-05-23Auto merge of #111869 - Dylan-DPC:rollup-9pydw08, r=Dylan-DPCbors-326/+208
Rollup of 6 pull requests Successful merges: - #111461 (Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic) - #111579 (Also assume wrap-around discriminants in `as` MIR building) - #111704 (Remove return type sized check hack from hir typeck) - #111853 (Check opaques for mismatch during writeback) - #111854 (rustdoc: clean up `settings.css`) - #111860 (Don't ICE if method receiver fails to unify with `arbitrary_self_types`) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-23Move BodyWithBorrowckFacts to consumersDominik Stolz-31/+34
2023-05-23Rollup merge of #111860 - compiler-errors:issue-111838, r=WaffleLapkinDylan DPC-8/+17
Don't ICE if method receiver fails to unify with `arbitrary_self_types` Consider: ```rust struct Foo(u32); impl Foo { fn get<R: Deref<Target=Self>>(self: R) -> u32 { self.0 } } fn main() { let mut foo = Foo(1); foo.get::<&Foo>(); } ``` The problem here is that with `arbitrary_self_types`, we're allowed to have a method receiver that mentions generics from the method itself (`fn get<R: Deref<Target=Self>>(self: R)`). Since we don't actually take into account the user-written turbofish generics when doing method lookup (nor do we check that method predicates hold), method probing will happily infer `R = Foo` during the probe. When we later confirm the method, we do use the turbofish'd subst and instead now have that `R = &Foo`. This doesn't unify with the self type we chose during the probe, causing an ICE. Getting this to work correctly will be difficult. Specifically, we'll need to actually pass in the turbofish generics for the method being probed for and check that the self type unifies considering those generics. This seems like a lot of work, and I'm not actually familiar with the restrictions originally called out for `#![feature(arbitrary_self_types)]`, but I think we should probably instead just deny having receivers that mention (type/const) generics that come from the method itself. But I mostly just want to turn this ICE into an error, so I'll leave that up for later PRs. Fixes #111838
2023-05-23Rollup merge of #111853 - compiler-errors:opaque-check, r=oli-obkDylan DPC-24/+62
Check opaques for mismatch during writeback Revive #111705. I realized that we don't need to put any substs in the writeback results since all of the hidden types have already been remapped. See the comment in `compiler/rustc_middle/src/ty/typeck_results.rs`, which should make that clear for other explorers of the codebase. Additionally, we need to do some diagnostic stashing because the diagnostics we produce during HIR typeck is very poor and we should prefer the diagnostic that comes from MIR, if we have one. r? `@oli-obk`
2023-05-23Rollup merge of #111704 - compiler-errors:sized-return-cleanup, r=oli-obkDylan DPC-248/+51
Remove return type sized check hack from hir typeck Remove a bunch of special-cased suggestions when someone returns `-> dyn Trait` that checks for type equality, etc. This was a pretty complex piece of code that also relied on a hack in hir typeck (see changes to `compiler/rustc_hir_typeck/src/check.rs`), and I'm not convinced that it's necessary to maintain, when all we really need to tell the user is that they should return `-> impl Trait` or `-> Box<dyn Trait>`, depending on their specific use-case. This is necessary because we may need to move the "return type is sized" check from hir typeck to wfcheck, which does not have access to typeck results. This is a prerequisite for that, and I'm fairly confident that the diagnostics "regressions" here are not a big deal.
2023-05-23Rollup merge of #111579 - scottmcm:enum-as-signed, r=oli-obkDylan DPC-43/+58
Also assume wrap-around discriminants in `as` MIR building Resolves this FIXME: https://github.com/rust-lang/rust/blob/8d18c32b61476ed16dd15074e71be3970368d6d7/compiler/rustc_mir_build/src/build/expr/as_rvalue.rs#L231 r? `@oli-obk`
2023-05-23Rollup merge of #111461 - oli-obk:crate_collision, r=petrochenkovDylan DPC-3/+20
Fix symbol conflict diagnostic mistakenly being shown instead of missing crate diagnostic This was a refactoring mistake in https://github.com/rust-lang/rust/pull/109213 fixes #111284
2023-05-23Make place helpers accessibleDominik Stolz-0/+2
2023-05-23Return promoteds in BodyWithBorrowckFactsDominik Stolz-0/+3
2023-05-23Allow consumers to retrieve borrowck outputJonáš Fiala-48/+111
2023-05-23Auto merge of #111807 - erikdesjardins:noalias, r=oli-obkbors-4/+31
[rustc_ty_utils] Treat `drop_in_place`'s *mut argument like &mut when adding LLVM attributes This resurrects PR #103614, which has sat idle for a while. This could probably use a new perf run, since we're on a new LLVM version now. r? `@oli-obk` cc `@RalfJung` --- LLVM can make use of the `noalias` parameter attribute on the parameter to `drop_in_place` in areas like argument promotion. Because the Rust compiler fully controls the code for `drop_in_place`, it can soundly deduce parameter attributes on it. In #103957, Miri was changed to retag `drop_in_place`'s argument as if it was `&mut`, matching this change.
2023-05-23Fix symbol conflict diagnostic mistakenly being shown instead of missing ↵Oli Scherer-3/+20
crate diagnostic
2023-05-23fix(resolve): not defined `extern crate shadow_name`bohan-1/+6
2023-05-23Auto merge of #110204 - compiler-errors:new-solver-hir-typeck-hacks, r=lcnrbors-40/+158
Deal with unnormalized projections when structurally resolving types with new solver 1. Normalize types in `structurally_resolved_type` when the new solver is enabled 2. Normalize built-in autoderef targets in `Autoderef` when the new solver is enabled 3. Normalize-erasing-regions in `resolve_type` in writeback This is motivated by the UI test provided, which currently fails with: ``` error[E0609]: no field `x` on type `<usize as SliceIndex<[Foo]>>::Output` --> <source>:9:11 | 9 | xs[0].x = 1; | ^ ``` I'm pretty happy with the approach in (1.) and (2.) and think we'll inevitably need something like this in the long-term, but (3.) seems like a hack to me. It's a *lot* of work to add tons of new calls to every user of these typeck results though (mir build, late lints, etc). Happy to discuss further. r? `@lcnr`
2023-05-23Don't ICE on RPITIT when promoting trait preds to associated type boundsMichael Goulet-0/+2
2023-05-23Don't ICE if method receiver fails to unify with arbitrary_self_typesMichael Goulet-8/+17
2023-05-22Check opaques for mismatch during writebackMichael Goulet-24/+62
2023-05-22Structurally normalize in the new solverMichael Goulet-24/+138
2023-05-22Normalize types in writeback results with new solverMichael Goulet-16/+20
2023-05-22Enable sanitizers and profiler for aarch64-unknown-linux-muslAlex Gaynor-1/+6
2023-05-22properly pretty-print inherent projectionsLeón Orell Valerian Liehr-4/+28
2023-05-22Auto merge of #111848 - Dylan-DPC:rollup-7jqydzg, r=Dylan-DPCbors-66/+78
Rollup of 6 pull requests Successful merges: - #111501 (MIR drive-by cleanups) - #111609 (Mark internal functions and traits unsafe to reflect preconditions) - #111612 (Give better error when collecting into `&[T]`) - #111756 (Rename `{drop,forget}_{copy,ref}` lints to more consistent naming) - #111843 (move lcnr to only review types stuff) - #111844 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-23Rollup merge of #111756 - Urgau:rename_drop_forget_copy_ref_lints, r=fee1-deadDylan DPC-22/+22
Rename `{drop,forget}_{copy,ref}` lints to more consistent naming This PR renames previous uplifted lints in https://github.com/rust-lang/rust/pull/109732 to more consistent naming. I followed the renaming done [here](https://github.com/rust-lang/rust/issues/53224) and also advocated in this [clippy issue](https://github.com/rust-lang/rust-clippy/issues/2845): - `drop_copy` to `dropping_copy_types` - `forget_copy` to `forgetting_copy_types` - `drop_ref` to `dropping_references` - `forget_ref` to `forgetting_references`
2023-05-23Rollup merge of #111612 - ChayimFriedman2:collect-into-slice-ref, r=petrochenkovDylan DPC-0/+8
Give better error when collecting into `&[T]` The detection of slice reference of `{integral}` in `rustc_on_unimplemented` is hacky, but a proper solution requires changing `FmtPrinter` to add a parameter to print integers as `{integral}` and I didn't want to change it just for `rustc_on_unimplemented`. I can do that if requested, though. I'm open to better wording; this is the best I could come up with.
2023-05-23Rollup merge of #111501 - WaffleLapkin:drivebycleanupuwu, r=oli-obkDylan DPC-44/+48
MIR drive-by cleanups Some random drive-by cleanups I did while working with MIR/THIR.
2023-05-22Auto merge of #111754 - lcnr:recursion-depth, r=matthewjasperbors-3/+26
fix recursion depth handling after confirmation fixes #111729 I think having to use `Obligation::with_depth` correctly everywhere is very hard because e.g. the nested obligations from `eq` currently do not have the correct obligation depth. The new solver [completely removes `recursion_depth` from obligations](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/traits/solve/struct.Goal.html) and instead tracks the depth in the solver itself which is far easier to get right. Moving the old solver towards this shouldn't be that hard but is probably somewhat annoying. r? `@matthewjasper`
2023-05-22rustc_privacy: Reach underlying types of `impl Trait`s in a separate passVadim Petrochenkov-17/+29
outside of fixed point iteration.
2023-05-22rustc_privacy: Merge three matches on `ItemKind` into oneVadim Petrochenkov-112/+61
and remove some more `Option`s as a result
2023-05-22rustc_privacy: Remove some `Option`sVadim Petrochenkov-32/+25
in cases where they are guaranteed to be `Some`
2023-05-22rustc_privacy: Migrate `EmbargoVisitor` to `visit_all_item_likes_in_crate`Vadim Petrochenkov-18/+1
Previously it had some logic requiring tree visiting, but it was moved to resolve last year.
2023-05-22Run AST validation on match guards correctlyMatthew Jasper-5/+8
2023-05-22Create a structure to define the features from to_llvm_features.Jamie Cunliffe-65/+128
Rather than returning an array of features from to_llvm_features, return a structure that contains the dependencies. This also contains metadata on how the features depend on each other to allow for the correct enabling and disabling.
2023-05-22Only disable folded features when it makes sense.Jamie Cunliffe-5/+31
Some features that are tied together only make sense to be folded together when enabling the feature. For example on AArch64 sve and neon are tied together, however it doesn't make sense to disable neon when disabling sve.
2023-05-22Tie neon with fp-armv8.Jamie Cunliffe-2/+4
In #91608 the fp-armv8 feature was removed as it's tied to the neon feature. However disabling neon didn't actually disable the use of floating point registers and instructions, for this `-fp-armv8` is required.
2023-05-22Auto merge of #111775 - compiler-errors:triple-check, r=Nilstriebbors-5/+44
Add extra debug assertions for equality for Adt/Variant/FieldDef Would've made it easier to both catch and test https://github.com/rust-lang/rust/pull/111494. Maybe not worth it, since it does mean that the compiler is doing extra work when debug-assertions are enabled, but also that's what debug assertions are for :^) This is a revival of #111523 because I think I pushed an empty branch and bors got a bit too excited it closed the PR.
2023-05-22update pulldown-cmark to 0.9.3Lukas Markeffsky-1/+1
2023-05-21Auto merge of #111808 - Zoxc:query-structs-trim, r=cjgillotbors-82/+77
Replace `QueryStruct` with arrays local to `rustc_query_impl` This removes `QueryStruct` and instead uses constant arrays of function pointers for `try_collect_active_jobs`, `alloc_self_profile_query_strings` and `encode_query_results`. This further decouples `rustc_query_impl` from `rustc_middle`. r? `@cjgillot`
2023-05-21Auto merge of #111731 - MU001999:fix/issue-111727, r=cjgillotbors-16/+10
Keep only the trait when emitting the error for `MyTrait + 'a` Fixes #111727
2023-05-21Auto merge of #111820 - matthiaskrgr:rollup-9sb2lw9, r=matthiaskrgrbors-22/+24
Rollup of 5 pull requests Successful merges: - #111745 (Fix overflow in error emitter) - #111770 (Read beta version from the version file if building from a source tarball) - #111797 (Migrate GUI colors test to original CSS color format) - #111809 (Unset MIRI_BLESS for mir-opt-level 4 miri tests) - #111817 (Migrate GUI colors test to original CSS color format) r? `@ghost` `@rustbot` modify labels: rollup
2023-05-21Rollup merge of #111745 - Badel2:emitter-add-overflow, r=compiler-errorsMatthias Krüger-22/+24
Fix overflow in error emitter Fix #109854 Close #94171 (was already fixed before but missing test) This bug happens when a multipart suggestion spans more than one line. The fix is to update the `acc` variable, which didn't handle the case when the text to remove spans multiple lines but the text to add spans only one line. Also, use `usize::try_from` instead of `as usize` to detect overflows earlier in the future, and point to the source of the overflow (the original issue points to a different place where this value is used, not where the overflow had happened). And finally add an `if start != end` check to avoid doing any extra work in case of empty ranges. Long explanation: Given this test case: ```rust fn generate_setter() { String::with_capacity( //~^ ERROR this function takes 1 argument but 3 arguments were supplied generate_setter, r#" pub(crate) struct Person<T: Clone> {} "#, r#""#, ); } ``` The compiler will try to convert that code into the following: ```rust fn generate_setter() { String::with_capacity( //~^ ERROR this function takes 1 argument but 3 arguments were supplied /* usize */, ); } ``` So it creates a suggestion with 3 separate parts: ``` // Replace "generate_setter" with "/* usize */" SubstitutionPart { span: fuzz_input.rs:4:5: 4:20 (#0), snippet: "/* usize */" } // Remove second arg (multiline string) SubstitutionPart { span: fuzz_input.rs:4:20: 7:3 (#0), snippet: "" } // Remove third arg (r#""#) SubstitutionPart { span: fuzz_input.rs:7:3: 8:11 (#0), snippet: "" } ``` Each of this parts gets a separate `SubstitutionHighlight` (this marks the relevant text green in a terminal, the values are 0-indexed so `start: 4` means column 5): ``` SubstitutionHighlight { start: 4, end: 15 } SubstitutionHighlight { start: 15, end: 15 } SubstitutionHighlight { start: 18446744073709551614, end: 18446744073709551614 } ``` The 2nd and 3rd suggestion are empty (start = end) because they only remove text, so there are no additions to highlight. But the 3rd span has overflowed because the compiler assumes that the 3rd suggestion is on the same line as the first suggestion. The 2nd span starts at column 20 and the highlight starts at column 16 (15+1), so that suggestion is good. But since the 3rd span starts at column 3, the result is `3 - 4`, or column -1, which turns into -2 with 0-indexed, and that's equivalent to `18446744073709551614 as isize`. With this fix, the resulting `SubstitutionHighlight` are: ``` SubstitutionHighlight { start: 4, end: 15 } SubstitutionHighlight { start: 15, end: 15 } SubstitutionHighlight { start: 15, end: 15 } ``` As expected. I guess ideally we shouldn't emit empty highlights when removing text, but I am too scared to change that.
2023-05-21Rename `forget_ref` lint to `forgetting_references`Urgau-6/+6
2023-05-21Rename `drop_ref` lint to `dropping_references`Urgau-7/+7