about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-06-20Auto merge of #112320 - compiler-errors:do-not-impl-via-obj, r=lcnrbors-2/+77
Add `implement_via_object` to `rustc_deny_explicit_impl` to control object candidate assembly Some built-in traits are special, since they are used to prove facts about the program that are important for later phases of compilation such as codegen and CTFE. For example, the `Unsize` trait is used to assert to the compiler that we are able to unsize a type into another type. It doesn't have any methods because it doesn't actually *instruct* the compiler how to do this unsizing, but this is later used (alongside an exhaustive match of combinations of unsizeable types) during codegen to generate unsize coercion code. Due to this, these built-in traits are incompatible with the type erasure provided by object types. For example, the existence of `dyn Unsize<T>` does not mean that the compiler is able to unsize `Box<dyn Unsize<T>>` into `Box<T>`, since `Unsize` is a *witness* to the fact that a type can be unsized, and it doesn't actually encode that unsizing operation in its vtable as mentioned above. The old trait solver gets around this fact by having complex control flow that never considers object bounds for certain built-in traits: https://github.com/rust-lang/rust/blob/2f896da247e0ee8f0bef7cd7c54cfbea255b9f68/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs#L61-L132 However, candidate assembly in the new solver is much more lovely, and I'd hate to add this list of opt-out cases into the new solver. Instead of maintaining this complex and hard-coded control flow, instead we can make this a property of the trait via a built-in attribute. We already have such a build attribute that's applied to every single trait that we care about: `rustc_deny_explicit_impl`. This PR adds `implement_via_object` as a meta-item to that attribute that allows us to opt a trait out of object-bound candidate assembly as well. r? `@lcnr`
2023-06-20Merge attrs, better validationMichael Goulet-0/+54
2023-06-20Add rustc_do_not_implement_via_objectMichael Goulet-2/+23
2023-06-19Rollup merge of #112781 - compiler-errors:new-solver-tait-overlaps-hidden, ↵Michael Goulet-0/+2
r=lcnr Don't consider TAIT normalizable to hidden ty if it would result in impossible item bounds See test for example where we shouldn't consider it possible to alias-relate a TAIT and hidden type. r? `@lcnr`
2023-06-19Rollup merge of #112596 - compiler-errors:missing-sig-with-rpitit, r=b-naberMichael Goulet-0/+59
Suggest correct signature on missing fn returning RPITIT/AFIT Add `async` and unpeel the future's output type if the function is async Fixes #108195
2023-06-19Rollup merge of #112499 - tgross35:py-ruff-fixes, r=Mark-SimulacrumMichael Goulet-3/+3
Fix python linting errors These were flagged by `ruff`, run using the config in https://github.com/rust-lang/rust/pull/112482
2023-06-19Rollup merge of #112232 - fee1-dead-contrib:match-eq-const-msg, r=b-naberMichael Goulet-0/+51
Better error for non const `PartialEq` call generated by `match` Resolves #90237
2023-06-19Auto merge of #112805 - matthiaskrgr:rollup-r5yrefu, r=matthiaskrgrbors-1/+98
Rollup of 7 pull requests Successful merges: - #109970 ([doc] `poll_fn`: explain how to `pin` captured state safely) - #112705 (Simplify `Span::source_callee` impl) - #112757 (Use BorrowFlag instead of explicit isize) - #112768 (Rewrite various resolve/diagnostics errors as translatable diagnostics) - #112777 (Continue folding in query normalizer on weak aliases) - #112780 (Treat TAIT equation as always ambiguous in coherence) - #112783 (Don't ICE on bound var in `reject_fn_ptr_impls`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-19Rollup merge of #112783 - compiler-errors:nlb-fnptr-reject-ice, r=fee1-deadMatthias Krüger-0/+40
Don't ICE on bound var in `reject_fn_ptr_impls` We may try to use an impl like `impl<T: FnPtr> PartialEq {}` to satisfy a predicate like `for<T> T: PartialEq` -- don't ICE in that case. Fixes #112735
2023-06-19Rollup merge of #112780 - compiler-errors:tait-is-ambig, r=lcnrMatthias Krüger-0/+45
Treat TAIT equation as always ambiguous in coherence Not sure why we weren't treating all TAIT equality as ambiguous -- this behavior combined with `DefineOpaqueTypes::No` leads to coherence overlap failures, since we incorrectly consider impls as not overlapping because the obligation `T: From<Foo>` doesn't hold. Fixes #112765
2023-06-19Rollup merge of #112777 - compiler-errors:normalize-weak-more, r=oli-obkMatthias Krüger-0/+12
Continue folding in query normalizer on weak aliases Fixes #112752 Fixes #112731 (same root cause, so didn't make a test for it) fixes #112776 r? ```@oli-obk```
2023-06-19Rollup merge of #112768 - NotStirred:translatable_diag/resolve1, r=WaffleLapkinMatthias Krüger-1/+1
Rewrite various resolve/diagnostics errors as translatable diagnostics additional question: For trivial strings is it ever accepted to use `fluent_generated::foo` in a `label` for example? Or is an empty struct `Diagnostic` preferred?
2023-06-19Auto merge of #112238 - scottmcm:mir-add-unchecked, r=cjgillotbors-167/+327
Promote unchecked integer math to MIR `BinOp`s So slice indexing by a range gets down to one basic block, for example. r? cjgillot
2023-06-19Remove unreachable and untested suggestion for invalid span enum derive(Default)Tom Martin-1/+1
2023-06-19Don't consider TAIT normalizable to hidden ty if it would result in ↵Michael Goulet-0/+2
impossible item bounds
2023-06-19Auto merge of #112366 - lukas-code:test, r=Nilstriebbors-0/+70
`#[test]` function signature verification improvements This PR contains two improvements to the expansion of the `#[test]` macro. The first one fixes https://github.com/rust-lang/rust/issues/112360 by correctly recovering item statements if the signature verification fails. The second one forbids non-lifetime generics on `#[test]` functions. These were previously allowed if the function returned `()`, but always caused an inference error: before: ```text error[E0282]: type annotations needed --> src/lib.rs:2:1 | 1 | #[test] | ------- in this procedural macro expansion 2 | fn foo<T>() {} | ^^^^^^^^^^^^^^ cannot infer type ``` after: ```text error: functions used as tests can not have any non-lifetime generic parameters --> src/lib.rs:2:1 | 2 | fn foo<T>() {} | ^^^^^^^^^^^^^^ ``` Also includes some basic tests for test function signature verification, because I couldn't find any (???) in the test suite.
2023-06-19Promote unchecked_add/sub/mul/shl/shr to mir::BinOpScott McMurray-167/+327
2023-06-19Auto merge of #112724 - scottmcm:simpler-unchecked-shifts, r=Mark-Simulacrumbors-87/+444
[libs] Simplify `unchecked_{shl,shr}` There's no need for the `const_eval_select` dance here. And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it in the `mir-opt/inline/unchecked_shifts` tests. We don't need `u32::checked_shl` doing a dance through both `Result` *and* `Option` 🙃
2023-06-19Don't ICE on bound var in reject_fn_ptr_implsMichael Goulet-0/+40
2023-06-18Treat TAIT equation as always ambiguous in coherenceMichael Goulet-0/+45
2023-06-18Continue folding in query normalizer on weak aliasesMichael Goulet-0/+12
2023-06-18Rollup merge of #112537 - compiler-errors:dont-record-adjustments-twice, ↵Michael Goulet-0/+46
r=cjgillot Don't record adjustments twice in `note_source_of_type_mismatch_constraint` We call `lookup_method` a few times in `note_source_of_type_mismatch_constraint`, but that function has side-effects to the typeck results. Replace it with a less side-effect-y variant of the function for use in diagnostics. Specifically the ICE in #112532 happens because we're recording deref adjustments twice for a call receiver, which causes `ExprUseVisitor` to be angry. Fixes #112532
2023-06-18Auto merge of #112636 - clubby789:no-capture-array-ref, r=cjgillotbors-18/+65
Don't capture `&[T; N]` when contents isn't read Fixes the check in #111831 Fixes #112607, although I decided to test the root cause rather than including the example in the issue as a test. cc `@BoxyUwU`
2023-06-18Better error for non const `PartialEq` call generated by `match`Deadbeef-0/+51
2023-06-17Auto merge of #100036 - DrMeepster:box_free_free_box, r=oli-obkbors-20/+22
Remove `box_free` lang item This PR removes the `box_free` lang item, replacing it with `Box`'s `Drop` impl. Box dropping is still slightly magic because the contained value is still dropped by the compiler.
2023-06-17Rollup merge of #112728 - Zalathar:spanview-charset, r=NilstriebMatthias Krüger-3/+6
Add `<meta charset="utf-8">` to `-Zdump-mir-spanview` output Without an explicit `<meta charset>` declaration, some browsers (e.g. Safari) won't detect the page encoding as UTF-8, causing unicode characters in the dump output to display incorrectly.
2023-06-17Rollup merge of #112707 - GuillaumeGomez:back-in-history-fix, r=notriddleMatthias Krüger-1/+8
[rustdoc] Fix invalid handling of "going back in history" when "go to only search result" setting is enabled You can test the fix [here](https://rustdoc.crud.net/imperio/back-in-history-fix/lib2/index.html). Enable "Directly go to item in search if there is only one result", then search for `HasALongTraitWithParams` and finally go back to previous page. It should be back on the `index.html` page. The reason for this bug is that the JS state is cached as is, so when we go back to the page, it resumes where it was left, somewhat (very weird), meaning the search is run again etc. The best way to handle this is to force the JS re-execution in this case so that it doesn't try to resume from where it left and then lead us back to the current page. r? ``@notriddle``
2023-06-17Rollup merge of #112683 - asquared31415:asm_clobber_ice, r=compiler-errorsMatthias Krüger-91/+183
fix ICE on specific malformed asm clobber_abi fixes #112635
2023-06-17Add `<meta charset="utf-8">` to `-Zdump-mir-spanview` outputZalathar-3/+6
2023-06-16Apply changes to fix python linting errorsTrevor Gross-3/+3
2023-06-17Auto merge of #108860 - oli-obk:tait_alias, r=compiler-errorsbors-88/+203
Add `AliasKind::Weak` for type aliases. `type Foo<T: Debug> = Bar<T>;` does not check `T: Debug` at use sites of `Foo<NotDebug>`, because in contrast to a ```rust trait Identity { type Identity; } impl<T: Debug> Identity for T { type Identity = T; } <NotDebug as Identity>::Identity ``` type aliases do not exist in the type system, but are expanded to their aliased type immediately when going from HIR to the type layer. Similarly: * a private type alias for a public type is a completely fine thing, even though it makes it a bit hard to write out complex times sometimes * rustdoc expands the type alias, even though often times users use them for documentation purposes * diagnostics show the expanded type, which is confusing if the user wrote a type alias and the diagnostic talks about another type that they don't know about. For type alias impl trait, these issues do not actually apply in most cases, but sometimes you have a type alias impl trait like `type Foo<T: Debug> = (impl Debug, Bar<T>);`, which only really checks it for `impl Debug`, but by accident prevents `Bar<T>` from only being instantiated after proving `T: Debug`. This PR makes sure that we always check these bounds explicitly and don't rely on an implementation accident. To not break all the type aliases out there, we only use it when the type alias contains an opaque type. We can decide to do this for all type aliases over an edition. Or we can later extend this to more types if we figure out the back-compat concerns with suddenly checking such bounds. As a side effect, easily allows fixing https://github.com/rust-lang/rust/issues/108617, which I did. fixes https://github.com/rust-lang/rust/issues/108617
2023-06-16fix ICE on specific malformed asm clobber_abiasquared31415-91/+183
2023-06-16[libs] Simplify `unchecked_{shl,shr}`Scott McMurray-87/+444
There's no need for the `const_eval_select` dance here. And while I originally wrote the `.try_into().unwrap_unchecked()` implementation here, it's kinda a mess in MIR -- this new one is substantially simpler, as shown by the old one being above the inlining threshold but the new one being below it.
2023-06-16Auto merge of #112716 - compiler-errors:rollup-h77daia, r=compiler-errorsbors-2/+51
Rollup of 7 pull requests Successful merges: - #111074 (Relax implicit `T: Sized` bounds on `BufReader<T>`, `BufWriter<T>` and `LineWriter<T>`) - #112226 (std: available_parallelism using native netbsd api first) - #112474 (Support 128-bit enum variant in debuginfo codegen) - #112662 (`#[lang_item]` for `core::ptr::Unique`) - #112665 (Make assumption functions in new solver take `Binder<'tcx, Clause<'tcx>>`) - #112684 (Disable alignment checks on i686-pc-windows-msvc) - #112706 (Add `SyntaxContext::is_root`) r? `@ghost` `@rustbot` modify labels: rollup
2023-06-16remove box_free and replace with drop implDrMeepster-20/+22
2023-06-16Rollup merge of #112684 - saethlin:ignore-windows-alignment, r=wesleywiserMichael Goulet-0/+22
Disable alignment checks on i686-pc-windows-msvc r? `@wesleywiser` Because you were in the Zulip discussion of this: https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-06-15 cc #112480
2023-06-16Rollup merge of #112474 - ldm0:ldm_enum_debuginfo_128_support, r=compiler-errorsMichael Goulet-2/+29
Support 128-bit enum variant in debuginfo codegen fixes #111600
2023-06-16Add `AliasKind::Weak` for type aliases.Oli Scherer-88/+203
Only use it when the type alias contains an opaque type. Also does wf-checking on such type aliases.
2023-06-16Add regression test for #112676Guillaume Gomez-1/+8
2023-06-16Auto merge of #112294 - saethlin:inline-me-maybe, r=oli-obkbors-929/+343
Ignore the always part of #[inline(always)] in MIR inlining `#[inline(always)]` is used in two cases: for functions that are so trivial it is always profitable to inline them, but also for functions which LLVM thinks are a bad inlining candidate, but which actually turn out to be profitable to inline. That second justification doesn't apply to the MIR inliner, so ignoring our cost estimation for these functions is not necessarily the right right thing to do. This is basically a wash on non-check runs and a perf benefit in check runs. There are some notable regressions, and I think we might be able to claw those back by turning `#[inline(always)]` into a stronger hint. But I think this PR stands decently on its own as a tidy simplification.
2023-06-16Ignore the always part of #[inline(always)] in MIR inliningBen Kimock-929/+343
2023-06-16Auto merge of #110688 - GuillaumeGomez:result-search-type, r=notriddle,jshabors-29/+6
rustdoc: Add search result item types after their name Here what it looks like: ![Screenshot from 2023-04-22 15-16-58](https://user-images.githubusercontent.com/3050060/233789566-b5f3f625-3b78-4c56-a7ee-0a4f2d62e667.png) The idea is to improve accessibility by providing this information directly in the text and not only in the text color. Currently we already use it for doc aliases and for primitive types, so I extended it to all types. r? `@notriddle`
2023-06-16Disable alignment checks on i686-pc-windows-msvcBen Kimock-0/+22
2023-06-16Rollup merge of #112642 - compiler-errors:interp-lit-err, r=nnethercoteDylan DPC-0/+18
Handle interpolated literal errors Not sure why it was doing a whole dance to re-match on the token kind when it seems like `Lit::from_token` does the right thing for both macro-arg and regular literals. Nothing seems to have regressed diagnostics-wise from the change, though. Fixes #112622 r? ``@nnethercote``
2023-06-16Rollup merge of #112443 - ↵Dylan DPC-0/+19
compiler-errors:next-solver-opportunistically-resolve-regions, r=lcnr Opportunistically resolve regions in new solver Use `opportunistic_resolve_var` during canonicalization to collapse some regions. We have to start using `CanonicalVarValues::is_identity_modulo_regions`. We also have to modify that function to consider responses like `['static, ^0, '^1, ^2]` to be an "identity" response, since because we opportunistically resolve regions, there's no longer a 1:1 mapping between canonical var values and bound var indices in the response... There's one nasty side-effect -- one test (`tests/ui/dyn-star/param-env-infer.rs`) starts to ICE because the certainty goes from `Yes` to `Maybe(Overflow)`... Not exactly sure why, though? Putting this up for discussion/investigation. r? ```@lcnr```
2023-06-16Rollup merge of #112399 - compiler-errors:closure-substs-root-universe, r=lcnrDylan DPC-0/+7
Instantiate closure synthetic substs in root universe In the UI test example, we end up generalizing an associated type (something like `<Map<Option<i32>, [closure upvars=?0]> as IntoIterator>::Item` generalizes into `<Map<Option<i32>, [closure upvars=?1]> as IntoIterator>::Item`) then assigning it to itself, emitting an alias-relate goal. This trivially holds via one of the normalizes-to candidates, instead of relating substs, so when closure analysis eventually sets `?0` to the actual upvars, `?1` never gets constrained. This ends up being reported as an ambiguity error during writeback. Instead, we can take advantage of the fact that we *know* the closure substs live in the root universe. This will prevent them being generalized, since they always can be named, and the alias-relate above never gets emitted at all. We can probably do this to a handful of other `next_ty_var` calls in typeck for variables that are clearly associated with the body of the program, but I wanted to limit this for now. Eventually, if we end up representing universes more faithfully like a tree or whatever, we can remove this and turn it back to just a call to `next_ty_var`. Note: This is incredibly order-dependent -- we need to be assigning a type variable that was created *before* the closure substs, and we also need to actually have an unnormalized type at the time of the assignment. This currently seems easiest to trigger during call argument analysis just due to the fact that we instantiate the call's substs, normalize, THEN check args. r? ```@lcnr```
2023-06-16Rollup merge of #112163 - bvanjoi:fix-105231-2, r=compiler-errorsDylan DPC-0/+38
fix: inline `predicate_may_hold_fatal` and remove expect call in it - Fixes #105231 - Discussion: https://github.com/rust-lang/rust/pull/111985#discussion_r1208888821 r? ``@compiler-errors``
2023-06-16fix: inline `predicate_may_hold_fatal`bohan-0/+38
2023-06-16Auto merge of #112346 - saethlin:no-comment, r=oli-obkbors-24090/+21801
Remove comments from mir-opt MIR dumps See https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Line.20numbers.20in.20mir-opt.20tests/near/363849874 In https://github.com/rust-lang/rust/pull/99780 there is mention that "there has been a zulip conversation about disabling line numbers with mixed opinions" which to me means that some people opposed this. I can't find the referenced conversation so... here we go. The current situation is quite chaotic. It's not hard to find MIR diffs which contain * Absolute line numbers * Relative line numbers * Substituted line numbers (LL) For example: https://github.com/rust-lang/rust/blob/408bbd040613f6776e0a7d05d582c81f4ddc189a/tests/mir-opt/inline/inline_shims.drop.Inline.diff#L10-L17 And sometimes adding a comment at the top of a mir-opt test generates a diff in the test because a line number changed: https://github.com/rust-lang/rust/pull/98112/files#diff-b8cf4bcce95078e6a3faf075e9abf6864872fb28a64d95c04f04513b9e3bbd81 And irrelevant changes to the standard library can generate diffs in mir-opt tests: https://github.com/rust-lang/rust/pull/110694/files#diff-bf96b0e7c67b8b272814536888fd9428c314991e155beae1f0a2a67f0ac47b2c https://github.com/rust-lang/rust/commit/769886cc35ce08b76839f4cf72b8af1161c432e1 I think we should, specifically in mir-opt tests, completely remove the comments, or insert placeholders for all line and column numbers.
2023-06-15Rollup merge of #112654 - aliemjay:closure-output-normalize, r=compiler-errorsGuillaume Gomez-0/+49
normalize closure output in equate_inputs_and_outputs Fixes #112604