about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-12-22Auto merge of #118824 - aliemjay:perf-region-cons, r=compiler-errorsbors-2/+2
use Vec for region constraints instead of BTreeMap ~1% perf gain Diagnostic regressions need more investigation. r? `@ghost`
2023-12-22Rollup merge of #119215 - mu001999:fix/119209, r=NilstriebMatthias Krüger-0/+12
Emits error if has bound regions Fixes #119209
2023-12-22Rollup merge of #119201 - durin42:overaligned-constant, r=Mark-SimulacrumMatthias Krüger-1/+1
tests: fix overaligned-constant to not over-specify getelementptr instr On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things. Fixes #119193. `@rustbot` label: +llvm-main
2023-12-23Update testr0cky-18/+6
2023-12-22Emits error if has bound regionsr0cky-0/+24
2023-12-22Auto merge of #118847 - eholk:for-await, r=compiler-errorsbors-0/+157
Add support for `for await` loops This adds support for `for await` loops. This includes parsing, desugaring in AST->HIR lowering, and adding some support functions to the library. Given a loop like: ```rust for await i in iter { ... } ``` this is desugared to something like: ```rust let mut iter = iter.into_async_iter(); while let Some(i) = loop { match core::pin::Pin::new(&mut iter).poll_next(cx) { Poll::Ready(i) => break i, Poll::Pending => yield, } } { ... } ``` This PR also adds a basic `IntoAsyncIterator` trait. This is partly for symmetry with the way `Iterator` and `IntoIterator` work. The other reason is that for async iterators it's helpful to have a place apart from the data structure being iterated over to store state. `IntoAsyncIterator` gives us a good place to do this. I've gated this feature behind `async_for_loop` and opened #118898 as the feature tracking issue. r? `@compiler-errors`
2023-12-22Auto merge of #116821 - Nadrieril:fix-opaque-ice, r=compiler-errorsbors-0/+247
Exhaustiveness: reveal opaque types properly Previously, exhaustiveness had no clear policy around opaque types. In this PR I propose the following policy: within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body. I'm not sure how consistent this is with other operations allowed on opaque types; I believe this will require FCP. From what I can tell, this doesn't change anything for non-empty types. The observable changes are: - when the real type is uninhabited, matches within the defining scopes can now rely on that for exhaustiveness, e.g.: ```rust #[derive(Copy, Clone)] enum Void {} fn return_never_rpit(x: Void) -> impl Copy { if false { match return_never_rpit(x) {} } x } ``` - this properly fixes ICEs like https://github.com/rust-lang/rust/issues/117100 that occurred because a same match could have some patterns where the type is revealed and some where it is not. Bonus subtle point: if `x` is opaque, a match like `match x { ("", "") => {} ... }` will constrain its type ([playground](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=901d715330eac40339b4016ac566d6c3)). This is not the case for `match x {}`: this will not constain the type, and will only compile if something else constrains the type to be empty. Fixes https://github.com/rust-lang/rust/issues/117100 r? `@oli-obk` Edited for precision of the wording [Included](https://github.com/rust-lang/rust/pull/116821#issuecomment-1813171764) in the FCP on this PR is this rule: > Within the body of an item that defines the hidden type of some opaque type, exhaustiveness checking on a value of that opaque type is performed using the concrete hidden type inferred in this body.
2023-12-22Auto merge of #119163 - fmease:refactor-ast-trait-bound-modifiers, ↵bors-17/+17
r=compiler-errors Refactor AST trait bound modifiers Instead of having two types to represent trait bound modifiers in the parser / the AST (`parser::ty::BoundModifiers` & `ast::TraitBoundModifier`), only to map one to the other later, just use `parser::ty::BoundModifiers` (moved & renamed to `ast::TraitBoundModifiers`). The struct type is more extensible and easier to deal with (see [here](https://github.com/rust-lang/rust/pull/119099/files#r1430749981) and [here](https://github.com/rust-lang/rust/pull/119099/files#r1430752116) for context) since it more closely models what it represents: A compound of two kinds of modifiers, constness and polarity. Modeling this as an enum (the now removed `ast::TraitBoundModifier`) meant one had to add a new variant per *combination* of modifier kind, which simply isn't scalable and which lead to a lot of explicit non-DRY matches. NB: `hir::TraitBoundModifier` being an enum is fine since HIR doesn't need to worry representing invalid modifier kind combinations as those get rejected during AST validation thereby immensely cutting down the number of possibilities.
2023-12-22Auto merge of #119097 - nnethercote:fix-EmissionGuarantee, r=compiler-errorsbors-13/+31
Fix `EmissionGuarantee` There are some problems with the `DiagCtxt` API related to `EmissionGuarantee`. This PR fixes them. r? `@compiler-errors`
2023-12-21tests: fix overaligned-constant to not over-specify getelementptr instrAugie Fackler-1/+1
On LLVM 18 we get slightly different arguments here, so it's easier to just regex those away. The important details are all still asserted as I understand things. Fixes #119193. @rustbot label: +llvm-main
2023-12-21Rollup merge of #119154 - surechen:fix_119067, r=fmeaseMatthias Krüger-32/+82
Simple modification of `non_lifetime_binders`'s diagnostic information to adapt to type binders fixes #119067 Replace diagnostic information "lifetime bounds cannot be used in this context" to "bounds cannot be used in this context". ```rust #![allow(incomplete_features)] #![feature(non_lifetime_binders)] trait Trait {} trait Trait2 where for <T: Trait> ():{} //~^ ERROR bounds cannot be used in this context ```
2023-12-21Auto merge of #119056 - cjgillot:codegen-overalign, r=wesleywiserbors-0/+36
Tolerate overaligned MIR constants for codegen. Fixes https://github.com/rust-lang/rust/issues/117761 cc `@saethlin`
2023-12-21Simple modification of diagnostic informationsurechen-32/+82
fixes #119067
2023-12-20Rollup merge of #119168 - petrochenkov:feedvis4, r=compiler-errorsMatthias Krüger-0/+14
resolve: Stop feeding visibilities for import list stems Fixes https://github.com/rust-lang/rust/issues/119126
2023-12-20Add `ItemKind::Ctor` to stable mirCelina G. Val-2/+8
2023-12-20Add a small test for the case that was crashingCelina G. Val-0/+78
2023-12-20Refactor AST trait bound modifiersLeón Orell Valerian Liehr-17/+17
2023-12-20resolve: Stop feeding visibilities for import list stemsVadim Petrochenkov-0/+14
2023-12-20Rollup merge of #119155 - Zalathar:async-fn, r=compiler-errorsGuillaume Gomez-0/+104
coverage: Check for `async fn` explicitly, without needing a heuristic The old code used a heuristic to detect async functions and adjust their coverage spans to produce better output. But there's no need to resort to a heuristic when we can just look back at the original definition and check whether the current function is actually an `async fn`. In addition to being generally nicer, this also gets rid of the one piece of code that specifically cares about `CoverageSpan::is_closure` representing an actual closure. All remaining code that inspects that field just uses it as an indication that the span is a hole that should be carved out of other spans, and then discarded. That opens up the possibility of introducing other kinds of “hole” spans, e.g. for nested functions/types/macros, and having them all behave uniformly. --- `@rustbot` label +A-code-coverage
2023-12-20Reveal opaque types in exhaustiveness checkingNadrieril-9/+39
2023-12-20Add testsNadrieril-0/+217
2023-12-20Auto merge of #119134 - petrochenkov:feedvis2, r=compiler-errorsbors-0/+37
resolve: Feed visibilities for unresolved trait impl items Fixes https://github.com/rust-lang/rust/issues/119073
2023-12-20Rollup merge of #119094 - celinval:smir-layout, r=compiler-errorsMatthias Krüger-4/+146
Add function ABI and type layout to StableMIR This change introduces a new module to StableMIR named `abi` with information from `rustc_target::abi` and `rustc_abi`, that allow users to retrieve more low level information required to perform bit-precise analysis. The layout of a type can be retrieved via `Ty::layout`, and the instance ABI can be retrieved via `Instance::fn_abi()`. To properly handle errors while retrieve layout information, we had to implement a few layout related traits. r? ```@compiler-errors```
2023-12-20Rollup merge of #119071 - lcnr:overflowo, r=compiler-errorsMatthias Krüger-1/+34
-Znext-solver: adapt overflow rules to avoid breakage Do not erase overflow constraints if they are from equating the impl header when normalizing[^1]. This should be the minimal change to not break crates depending on the old project behavior of "apply impl constraints while only lazily evaluating any nested goals". Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/70, see https://hackmd.io/ATf4hN0NRY-w2LIVgeFsVg for the reasoning behind this. Only keeping constraints on overflow for `normalize-to` goals as that's the only thing needed for backcompat. It also allows us to not track the origin of root obligations. The issue with root goals would be something like the following: ```rust trait Foo {} trait Bar {} trait FooBar {} impl<T: Foo + Bar> FooBar for T {} // These two should behave the same, rn we can drop constraints for both, // but if we don't drop `Misc` goals we would only drop the constraints for // `FooBar` unless we track origins of root obligations. fn func1<T: Foo + Bar>() {} fn func2<T: FooBaz>() {} ``` [^1]: mostly, the actual rules are slightly different r? ``@compiler-errors``
2023-12-20Rollup merge of #118973 - Enselic:fix-IncorrectCguReuseType, r=michaelwoeristerMatthias Krüger-10/+14
rustc_codegen_ssa: Don't drop `IncorrectCguReuseType` , make `rustc_expected_cgu_reuse` attr work In [100753], `IncorrectCguReuseType` accidentally stopped being emitted by removing `diag.span_err(...)`. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. We assume that there are no bugs and that the currently actual CGU reuse is correct. If there are bugs, they will be discovered and fixed eventually, and the tests will then be updated. [100753]: https://github.com/rust-lang/rust/pull/100753/commits/706452eba74026c51e8d0fa30aee2497c69eafc0#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84 Closes #118972
2023-12-20Rollup merge of #118691 - chfogelman:improve-cstr-error, r=fmeaseMatthias Krüger-0/+129
Add check for possible CStr literals in pre-2021 Fixes [#118654](https://github.com/rust-lang/rust/issues/118654) Adds information to errors caused by possible CStr literals in pre-2021. The lexer separates `c"str"` into two tokens if the edition is less than 2021, which later causes an error when parsing. This error now has a more helpful message that directs them to information about editions. However, the user might also have written `c "str"` in a later edition, so to not confuse people who _are_ using a recent edition, I also added a note about whitespace. We could probably figure out exactly which scenario has been encountered by examining spans and editions, but I figured it would be better not to overcomplicate the creation of the error too much. This is my first code PR and I tried to follow existing conventions as much as possible, but I probably missed something, so let me know!
2023-12-20coverage: Add a test for `async` blocksZalathar-0/+104
We have coverage tests that use async functions, but none that use async blocks.
2023-12-20Auto merge of #106790 - the8472:rawvec-niche, r=scottmcmbors-9/+21
add more niches to rawvec Previously RawVec only had a single niche in its `NonNull` pointer. With this change it now has `isize::MAX` niches since half the value-space of the capacity field is never needed, we can't have a capacity larger than isize::MAX.
2023-12-19Add additional tests and update existing testsEric Holk-1/+109
2023-12-19Improve compiler error for c-strings in pre-2021Carter Hunt Fogelman-0/+129
2023-12-19Auto merge of #119112 - Nadrieril:remove-target_blocks-hack, r=matthewjasperbors-21/+21
match lowering: Remove the `make_target_blocks` hack This hack was introduced 4 years ago in [`a1d0266` (#60730)](https://github.com/rust-lang/rust/pull/60730/commits/a1d0266878793bc8b2bf50958eb529005ed19da0) to improve LLVM optimization time, specifically noticed in the `encoding` benchmark. Measurements today indicate it is no longer needed. r? `@matthewjasper`
2023-12-19Desugar for await loopsEric Holk-0/+24
2023-12-19Plumb awaitness of for loopsEric Holk-0/+25
2023-12-19resolve: Feed visibilities for unresolved trait impl itemsVadim Petrochenkov-0/+37
2023-12-19rustc_codegen_ssa: Don't let `IncorrectCguReuseType` errors get lostMartin Nordholts-10/+14
In [100753], `IncorrectCguReuseType` accidentally stopped being emitted. Begin emitting it again rather than just blindly dropping it, and adjust tests accordingly. [100753]: https://github.com/rust-lang/rust/pull/100753/commits/706452eba74026c51e8d0fa30aee2497c69eafc0#diff-048389738ddcbe0f9765291a29db1fed9a5f03693d4781cfb5aaa97ffb3c7f84
2023-12-19Fix c_variadic flag and add opaque info to PassModeCelina G. Val-4/+30
We should expand the information in PassMode later.
2023-12-19Remove the `make_target_blocks` hackNadrieril-21/+21
It was introduced 4 years ago in a1d0266878793bc8 to improve LLVM optimization time. Measurements today indicate it is no longer needed.
2023-12-19De-weirdify `fatally_break_rust`.Nicholas Nethercote-2/+20
The easter egg ICE on `break rust` is weird: it's the one ICE in the entire compiler that doesn't immediately abort, which makes it annoyingly inconsistent. This commit changes it to abort. As part of this, the extra notes are now appended onto the bug dignostic, rather than being printed as individual note diagnostics, which changes the output format a bit. These changes don't interferes with the joke, but they do help with my ongoing cleanups to error handling.
2023-12-19Rollup merge of #119098 - compiler-errors:hangs, r=lcnrMatthias Krüger-13/+18
Adjust the ignore-compare-mode-next-solver for hangs Some new tests hang, some old tests don't hang. r? lcnr or anyone in `@rust-lang/initiative-trait-system-refactor`
2023-12-19Rollup merge of #119091 - compiler-errors:alias-eq-in-structural-normalize, ↵Matthias Krüger-19/+18
r=lcnr Use alias-eq in structural normalization We don't need to register repeated normalizes-to goals in a loop in structural normalize, but instead we can piggyback on the fact that alias-eq will already normalize aliases until they are rigid. This fixes rust-lang/trait-system-refactor-initiative#78. r? lcnr
2023-12-19Auto merge of #119047 - mu001999:fix/118772, r=wesleywiserbors-0/+15
Check generic params after sigature for main-fn-ty Fixes #118772
2023-12-19Auto merge of #119061 - compiler-errors:async-gen-abi, r=wesleywiserbors-0/+89
Desugar `yield` in `async gen` correctly, ensure `gen` always returns unit 1. Ensure `async gen` blocks desugar `yield $expr` to `task_context = yield async_gen_ready($expr)`. Previously we were not assigning the `task_context` correctly, meaning that `yield` expressions in async generators returned type `ResumeTy` instead of `()`, and that we were not storing the `task_context` (which is probably unsound if we were reading the old task-context which has an invalidated borrow or something...) 2. Ensure that all `(async?) gen` blocks and `(async?) gen` fns return unit. Previously we were only checking this for `gen fn`, meaning that `gen {}` and `async gen {}` and `async gen fn` were allowed to return values that weren't unit. This is why #119058 was an ICE rather than an E0308. Fixes #119058.
2023-12-18Add a test demonstrating that RFC's note on diverging returns is subsumed by ↵Michael Goulet-0/+20
just inferring unit as ret type
2023-12-18Adjust the ignore-compare-mode-next-solver for hangsMichael Goulet-13/+18
2023-12-19Add `level` arg to `into_diagnostic`.Nicholas Nethercote-11/+11
And make all hand-written `IntoDiagnostic` impls generic, by using `DiagnosticBuilder::new(dcx, level, ...)` instead of e.g. `dcx.struct_err(...)`. This means the `create_*` functions are the source of the error level. This change will let us remove `struct_diagnostic`. Note: `#[rustc_lint_diagnostics]` is added to `DiagnosticBuilder::new`, it's necessary to pass diagnostics tests now that it's used in `into_diagnostic` functions.
2023-12-18Check const_eval_select intrinsic correctlyMichael Goulet-17/+22
2023-12-18Check FnPtr/FnDef built-in fn traits correctly with effectsMichael Goulet-2/+13
2023-12-18Add function ABI and type layout to StableMIRCelina G. Val-4/+120
This change introduces a new module to StableMIR named `abi` with information from `rustc_target::abi` and `rustc_abi`, that allow users to retrieve more low level information required to perform bit-precise analysis. The layout of a type can be retrieved via `Ty::layout`, and the instance ABI can be retrieved via `Instance::fn_abi()`. To properly handle errors while retrieve layout information, we had to implement a few layout related traits.
2023-12-18Use alias-eq in structural normalizationMichael Goulet-19/+18
2023-12-18Check generic params after sigature for main-fn-tyr0cky-0/+15