about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-12-08Add Bevy related test casesSantiago Pastorino-0/+97
2023-12-08Add tests related to normalization in implied boundsSantiago Pastorino-8/+105
2023-12-08Auto merge of #118668 - fmease:resolve-assoc-item-bindings-by-namespace, ↵bors-81/+199
r=compiler-errors Resolve associated item bindings by namespace This is the 3rd commit split off from #118360 with tests reblessed (they no longer contain duplicated diags which were caused by 4c0addc80af4666f26d7ad51fe34a0e2dd0b8b74) & slightly adapted (removed supertraits from a UI test, cc #118040). > * Resolve all assoc item bindings (type, const, fn (feature `return_type_notation`)) by namespace instead of trying to resolve a type first (in the non-RTN case) and falling back to consts afterwards. This is consistent with RTN. E.g., for `Tr<K = {…}>` we now always try to look up assoc consts (this extends to supertrait bounds). This gets rid of assoc tys shadowing assoc consts in assoc item bindings which is undesirable & inconsistent (types and consts live in different namespaces after all) > * Consolidate the resolution of assoc {ty, const} bindings and RTN (dedup, better diags for RTN) > * Fix assoc consts being labeled as assoc *types* in several diagnostics > * Make a bunch of diagnostics translatable Fixes #112560 (error → pass). As discussed r? `@compiler-errors` --- **Addendum**: What I call “associated item bindings” are commonly referred to as “type bindings” for historical reasons. Nowadays, “type bindings” include assoc type bindings, assoc const bindings and RTN (return type notation) which is why I prefer not to use this outdated term.
2023-12-08Rollup merge of #118709 - oksbsb:fix-job-server, r=SparrowLiiMatthias Krüger-4/+0
fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before use override #118589, resolve merge conflict `@petrochenkov` `@SparrowLii` Thanks!
2023-12-08Rollup merge of #118677 - GuillaumeGomez:doc_cfg-display, r=notriddleMatthias Krüger-0/+31
[rustdoc] Fix display of features Fixes https://github.com/rust-lang/rust/issues/118615. It now looks like this: ![image](https://github.com/rust-lang/rust/assets/3050060/6e77204e-0706-44a3-89ae-2dbd1934ebbc) We can't use flex without breaking the flow, meaning we can't vertically align items as we want. Because of that, the `min-height` was problematic as it rendered weirdly and therefore needed to be removed. r? `@notriddle`
2023-12-08Auto merge of #118725 - lcnr:normalizes-to-projection-split-3, r=BoxyUwUbors-11/+57
split `NormalizesTo` out of `Projection` 3 third attempt at #112658. Rebasing #116262 is very annoying, so I am doing it again from scratch. We should now be able to merge it without regressing anything as we handle occurs check failures involving aliases correctly since #117088. see https://hackmd.io/ktEL8knTSYmtdfrMMnA-Hg fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/1 r? `@compiler-errors`
2023-12-081. fix jobserver GLOBAL_CLIENT_CHECKED uninitialized before useoksbsb-4/+0
2. jobserver::initialize_checked should call before build_session, still should use EarlyErrorHandler, so revert stderr change in #118635
2023-12-08add regression testslcnr-0/+43
2023-12-08implement and use `NormalizesTo`lcnr-11/+14
2023-12-08Auto merge of #118442 - tmiasko:fuel-inc, r=lqdbors-0/+11
-Zfuel is incompatible with incremental compilation
2023-12-08Fuel is incompatible with incremental compilationTomasz Miąsko-0/+11
2023-12-07Auto merge of #118723 - matthiaskrgr:rollup-409e9u1, r=matthiaskrgrbors-57/+87
Rollup of 6 pull requests Successful merges: - #116420 (discard invalid spans in external blocks) - #118686 (Only check principal trait ref for object safety) - #118688 (Add method to get type of an Rvalue in StableMIR) - #118707 (Ping GuillaumeGomez for changes in rustc_codegen_gcc) - #118712 (targets: remove not-added {i386,i486}-unknown-linux-gnu) - #118719 (CFI: Add char to CFI integer normalization) Failed merges: - #117586 (Uplift the (new solver) canonicalizer into `rustc_next_trait_solver`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-07Resolve assoc item bindings by namespaceLeón Orell Valerian Liehr-81/+199
If a const is expected, resolve a const. If a type is expected, resolve a type. Don't try to resolve a type first falling back to consts.
2023-12-07Rollup merge of #118719 - rcvalle:rust-cfi-normalize-integers-118032, ↵Matthias Krüger-57/+20
r=compiler-errors CFI: Add char to CFI integer normalization Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Rollup merge of #116420 - bvanjoi:fix-116203, r=NilstriebMatthias Krüger-0/+67
discard invalid spans in external blocks Fixes #116203 This PR has discarded the invalid `const_span`, thereby making the format more neat. r? ``@Nilstrieb``
2023-12-07Auto merge of #118568 - DianQK:no-builtins-symbols, r=pnkfelixbors-0/+8
Avoid adding builtin functions to `symbols.o` We found performance regressions in #113923. The problem seems to be that `--gc-sections` does not remove these symbols. I tested that lld removes these symbols, but ld and gold do not. I found that `used` adds symbols to `symbols.o` at https://github.com/rust-lang/rust/blob/3e202ead604be31f4c1a5798a296953d3159da7e/compiler/rustc_codegen_ssa/src/back/linker.rs#L1786-L1791. The PR removes builtin functions. Note that under LTO, ld still preserves these symbols. (lld will still remove them.) The first commit also fixes #118559. But I think the second commit also makes sense.
2023-12-07CFI: Add char to CFI integer normalizationRamon de C Valle-57/+20
Adds char to CFI integer normalization to conform to #118032 for cross-language CFI support.
2023-12-07Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlinbors-126/+205
compile-time evaluation: detect writes through immutable pointers This has two motivations: - it unblocks https://github.com/rust-lang/rust/pull/116745 (and therefore takes a big step towards `const_mut_refs` stabilization), because we can now detect if the memory that we find in `const` can be interned as "immutable" - it would detect the UB that was uncovered in https://github.com/rust-lang/rust/pull/117905, which was caused by accidental stabilization of `copy` functions in `const` that can only be called with UB When UB is detected, we emit a future-compat warn-by-default lint. This is not a breaking change, so completely in line with [the const-UB RFC](https://rust-lang.github.io/rfcs/3016-const-ub.html), meaning we don't need t-lang FCP here. I made the lint immediately show up for dependencies since it is nearly impossible to even trigger this lint without `const_mut_refs` -- the accidentally stabilized `copy` functions are the only way this can happen, so the crates that popped up in #117905 are the only causes of such UB (in the code that crater covers), and the three cases of UB that we know about have all been fixed in their respective crates already. The way this is implemented is by making use of the fact that our interpreter is already generic over the notion of provenance. For CTFE we now use the new `CtfeProvenance` type which is conceptually an `AllocId` plus a boolean `immutable` flag (but packed for a more efficient representation). This means we can mark a pointer as immutable when it is created as a shared reference. The flag will be propagated to all pointers derived from this one. We can then check the immutable flag on each write to reject writes through immutable pointers. I just hope perf works out.
2023-12-07also print 'immutable' flagRalf Jung-111/+111
2023-12-07compile-time evaluation: emit a lint when a write through an immutable ↵Ralf Jung-15/+94
pointer occurs
2023-12-07Auto merge of #118635 - nnethercote:fewer-early-errors, r=davidtwcobors-0/+4
Fewer early errors r? `@davidtwco`
2023-12-07Extend GUI tests for `doc_cfg`Guillaume Gomez-0/+31
2023-12-06Auto merge of #118687 - matthiaskrgr:rollup-317ztgu, r=matthiaskrgrbors-175/+168
Rollup of 6 pull requests Successful merges: - #117981 (Remove deprecated `--check-cfg` syntax) - #118177 (Suppress warnings in LLVM wrapper when targeting MSVC) - #118317 (tip for define macro name after `macro_rules!`) - #118504 (Enforce `must_use` on associated types and RPITITs that have a must-use trait in bounds) - #118660 (rustc_arena: add `alloc_str`) - #118681 (Fix is_foreign_item for StableMIR instance ) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-06Rollup merge of #118681 - celinval:fix-foreign-item, r=ouz-aMatthias Krüger-2/+6
Fix is_foreign_item for StableMIR instance Change the implementation of `Instance::is_foreign_item` to directly query the compiler for the instance `def_id` instead of incorrectly relying on the conversion to `CrateItem`. I also added a method to check if the instance has body, since the function already existed and it just wasn't exposed via public APIs. This makes it much cheaper for the user to check if the instance has body. ## Background: - In pull https://github.com/rust-lang/rust/pull/118524, I fixed the conversion from Instance to CrateItem to avoid the conversion if the instance didn't have a body available. This broke the `is_foreign_item`. r? `@ouz-a`
2023-12-06Rollup merge of #118504 - compiler-errors:must-use, r=WaffleLapkinMatthias Krüger-0/+53
Enforce `must_use` on associated types and RPITITs that have a must-use trait in bounds Warn when an RPITIT or (un-normalized) associated type with a `#[must_use]` trait in its bounds is unused. This is pending T-lang approval, since it changes the semantics of the `#[must_use]` attribute slightly, but I think it strictly catches more strange errors. I could also limit this to just RPITITs, but that seems less useful. Fixes #118444
2023-12-06Rollup merge of #118317 - bvanjoi:fix-118295, r=petrochenkovMatthias Krüger-0/+19
tip for define macro name after `macro_rules!` Fixes #118295 ~Note that there are some bad case such as `macro_rules![]` or `macro_rules!()`. However, I think these are acceptable as they are likely to be seldom used (feel free to close this if you think its shortcomings outweigh its benefits)~ Edit: this problem was resolved by utilizing the `source_map.span_to_next_source`. r? `@petrochenkov`
2023-12-06Rollup merge of #117981 - Urgau:check-cfg-remove-deprecated-syntax, r=b-naberMatthias Krüger-173/+90
Remove deprecated `--check-cfg` syntax This PR removes the deprecated `--check-cfg` `names(...)` and `values(...)` syntax. Follow up to https://github.com/rust-lang/rust/pull/111072 Part of https://github.com/rust-lang/compiler-team/issues/636 r? compiler
2023-12-06Auto merge of #117936 - mu001999:master, r=petrochenkovbors-0/+20
Use the glob binding in resolve_rustdoc_path process Fixes #117920 Returning `None` seems enough. I reproduces and tests this locally by `cargo +stage1 build`, but I cannot reproduce this ICE by putting [the following code](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=8b3ca8f4a7676eb90baf30437ba041a2) into `tests/ui/...` and then compiling it using `rustc +stage1 /path/to/test.rs` or `x.py test`: ```rust #![crate_type = "lib"] use super::Hasher; /// [`Hasher`] pub use core::hash::*; ``` r? `@petrochenkov`
2023-12-06Also add an API to check if an instance has bodyCelina G. Val-3/+6
This is much cheaper than building a body just for the purpose of checking if the body exists.
2023-12-06Fix `is_foreign_item` for StableMIR instanceCelina G. Val-1/+2
Change the implementation of `Instance::is_foreign_item` to directly query the compiler for the instance `def_id` instead of incorrectly relying on the conversion to `CrateItem`. Background: - In pull https://github.com/rust-lang/rust/pull/118524, I fixed the conversion from Instance to CrateItem to avoid the conversion if the instance didn't have a body available. This broke the `is_foreign_item`.
2023-12-06Auto merge of #118679 - matthiaskrgr:rollup-zr1l9w6, r=matthiaskrgrbors-3/+245
Rollup of 7 pull requests Successful merges: - #116496 (Provide context when `?` can't be called because of `Result<_, E>`) - #117563 (docs: clarify explicitly freeing heap allocated memory) - #117874 (`riscv32` platform support) - #118516 (Add ADT variant infomation to StableMIR and finish implementing TyKind::internal()) - #118650 (add comment about keeping flags in sync between bootstrap.py and bootstrap.rs) - #118664 (docs: remove #110800 from release notes) - #118669 (library: fix comment about const assert in win api) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-06Rollup merge of #118516 - celinval:smir-variants, r=ouz-aMatthias Krüger-0/+115
Add ADT variant infomation to StableMIR and finish implementing TyKind::internal() Introduce a `VariantDef` type and a mechanism to retrieve the definition from an `AdtDef`. The `VariantDef` representation itself is just a combination of `AdtDef` and `VariantIdx`, which allow us to retrieve further information of a variant. I don't think we need to cache extra information for now, and we can translate on an on demand manner. I am leaving the fields public today due to https://github.com/rust-lang/project-stable-mir/issues/56, but they shouldn't. For this PR, I've only added a method to retrieve the variant name, and its fields. I also added an implementation of `RustcInternal` that allow users to retrieve more information using Rust internal APIs. I have also finished the implementation of `RustcInternal` for `TyKind` which fixes https://github.com/rust-lang/project-stable-mir/issues/46. ## Motivation Both of these changes are needed in order to properly interpret things like projections. For example, - The variant definition is used to find out which variant we are downcasting to. - Being able to create `Ty` from `TyKind` helps for example processing each stage of a projection, like the code in `place.ty()`.
2023-12-06Rollup merge of #116496 - estebank:question-method-chain-context, ↵Matthias Krüger-3/+130
r=compiler-errors Provide context when `?` can't be called because of `Result<_, E>` When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:27:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this has type `Result<_, String>` ... LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<_, ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-06Auto merge of #118605 - fee1-dead-contrib:rm-rustc_host, r=compiler-errorsbors-6/+7
Remove `#[rustc_host]`, use internal desugaring Also removed a way for users to explicitly specify the host param since that isn't particularly useful. This should eliminate any pain with encoding attributes across crates and etc. r? `@compiler-errors`
2023-12-06tip for define macro name after `macro_rules!`bohan-0/+19
2023-12-06Use the glob binding in resolve_rustdoc_path processr0cky-0/+20
2023-12-06Auto merge of #117661 - TheLazyDutchman:point_out_shadowed_associated_types, ↵bors-0/+61
r=petrochenkov Added shadowed hint for overlapping associated types Previously, when you tried to set an associated type that is shadowed by an associated type in a subtrait, like this: ```rust trait A { type X; } trait B: A { type X; // note: this is legal } impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { fn clone(&self) -> Self { todo!() } } you got a confusing error message, that says nothing about the shadowing: error[E0719]: the value of the associated type `X` (from trait `B`) is already specified --> test.rs:9:34 | 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | --- ^^^ re-bound here | | | `X` bound here first error[E0191]: the value of the associated type `X` (from trait `A`) must be specified --> test.rs:9:27 | 2 | type X; | ------ `X` defined here ... 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | ^^^^^^^^^^^ help: specify the associated type: `B<X=Y, X=Y, X = Type>` error: aborting due to 2 previous errors Some errors have detailed explanations: E0191, E0719. For more information about an error, try `rustc --explain E0191`. ``` Now instead, the error shows that the associated type is shadowed, and suggests renaming as a potential fix. ```rust error[E0719]: the value of the associated type `X` in trait `B` is already specified --> test.rs:9:34 | 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | --- ^^^ re-bound here | | | `X` bound here first error[E0191]: the value of the associated type `X` in `A` must be specified --> test.rs:9:27 | 2 | type X; | ------ `A::X` defined here ... 6 | type X; // note: this is legal | ------ `A::X` shadowed here ... 9 | impl<Y> Clone for Box<dyn B<X=Y, X=Y>> { | ^^^^^^^^^^^ associated type `X` must be specified | help: consider renaming this associated type --> test.rs:2:5 | 2 | type X; | ^^^^^^ help: consider renaming this associated type --> test.rs:6:5 | 6 | type X; // note: this is legal | ^^^^^^ ``` error: aborting due to 2 previous errors Some errors have detailed explanations: E0191, E0719. For more information about an error, try `rustc --explain E0191`. The rename help message is only emitted when the trait is local. This is true both for the supertrait as for the subtrait. There might be cases where you can use the fully qualified path (for instance, in a where clause), but this PR currently does not deal with that. fixes #100109 (continues from #117642, because I didn't know renaming the branch would close the PR)
2023-12-06Point out shadowed associated typesTheLazyDutchman-0/+61
Shadowing the associated type of a supertrait is allowed. This however makes it impossible to set the associated type of the supertrait in a dyn object. This PR makes the error message for that case clearer, like adding a note that shadowing is happening, as well as suggesting renaming of one of the associated types. r=petrochenckov
2023-12-06Auto merge of #118655 - compiler-errors:rollup-vrngyzn, r=compiler-errorsbors-38/+131
Rollup of 9 pull requests Successful merges: - #117793 (Update variable name to fix `unused_variables` warning) - #118123 (Add support for making lib features internal) - #118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always) - #118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence) - #118350 (Simplify Default for tuples) - #118450 (Use OnceCell in cell module documentation) - #118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`) - #118587 (Cleanup error handlers some more) - #118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-05Reduce verbosity of errorEsteban Küber-27/+3
2023-12-05Detect incorrect `;` in `Option::ok_or_else` and `Result::map_err`Esteban Küber-7/+17
Fix #72124.
2023-12-05Point at fewer methods in the chain, only those that change the E typeEsteban Küber-24/+17
2023-12-05Provide context when `?` can't be called because of `Result<_, E>`Esteban Küber-3/+151
When a method chain ending in `?` causes an E0277 because the expression's `Result::Err` variant doesn't have a type that can be converted to the `Result<_, E>` type parameter in the return type, provide additional context of which parts of the chain can and can't support the `?` operator. ``` error[E0277]: `?` couldn't convert the error to `String` --> $DIR/question-mark-result-err-mismatch.rs:28:25 | LL | fn bar() -> Result<(), String> { | ------------------ expected `String` because of this LL | let x = foo(); | ----- this can be annotated with `?` because it has type `Result<String, String>` LL | let one = x LL | .map(|s| ()) | ----------- this can be annotated with `?` because it has type `Result<(), String>` LL | .map_err(|_| ())?; | ---------------^ the trait `From<()>` is not implemented for `String` | | | this can't be annotated with `?` because it has type `Result<(), ()>` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = help: the following other types implement trait `From<T>`: <String as From<char>> <String as From<Box<str>>> <String as From<Cow<'a, str>>> <String as From<&str>> <String as From<&mut str>> <String as From<&String>> = note: required for `Result<(), String>` to implement `FromResidual<Result<Infallible, ()>>` ``` Fix #72124.
2023-12-06Fewer early errors.Nicholas Nethercote-0/+4
`build_session` is passed an `EarlyErrorHandler` and then constructs a `Handler`. But the `EarlyErrorHandler` is still used for some time after that. This commit changes `build_session` so it consumes the passed `EarlyErrorHandler`, and also drops it as soon as the `Handler` is built. As a result, `parse_cfg` and `parse_check_cfg` now take a `Handler` instead of an `EarlyErrorHandler`.
2023-12-05Change ty_with_args to return Ty instead of ResultCelina G. Val-0/+115
Although, we would like to avoid crashes whenever possible, and that's why I wanted to make this API fallible. It's looking pretty hard to do proper validation. I think many of our APIs will unfortunately depend on the user doing the correct thing since at the MIR level we are working on, we expect types to have been checked already.
2023-12-05Rollup merge of #118585 - sjwang05:issue-118564, r=compiler-errorsMichael Goulet-1/+11
Fix parser ICE when recovering `dyn`/`impl` after `for<...>` Fixes #118564
2023-12-05Rollup merge of #118346 - compiler-errors:deeply-normalize-for-diagnostic, ↵Michael Goulet-0/+49
r=lcnr Add `deeply_normalize_for_diagnostics`, use it in coherence r? lcnr Normalize trait refs used for coherence error reporting with `-Ztrait-solver=next-coherence`. Two things: 1. I said before that we can't add this to `TyErrCtxt` because we compute `OverlapResult`s even if there are no diagnostics being emitted, e.g. for a reservation impl. 2. I didn't want to add this to an `InferCtxtExt` trait because I felt it was unnecessary. I don't particularly care about the API though.
2023-12-05Rollup merge of #118268 - compiler-errors:pretty-print, r=estebankMichael Goulet-37/+37
Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always It's almost always better, at least in diagnostics, to print `Fn(i32, u32)` instead of `Fn<(i32, u32)>`. Related to but doesn't fix #118225. That needs a separate fix.
2023-12-05Rollup merge of #118123 - RalfJung:internal-lib-features, r=compiler-errorsMichael Goulet-0/+34
Add support for making lib features internal We have the notion of an "internal" lang feature: a feature that is never intended to be stabilized, and using which can cause ICEs and other issues without that being considered a bug. This extends that idea to lib features as well. It is an alternative to https://github.com/rust-lang/rust/pull/115623: instead of using an attribute to declare lib features internal, we simply do this based on the name. Everything ending in `_internals` or `_internal` is considered internal. Then we rename `core_intrinsics` to `core_intrinsics_internal`, which fixes https://github.com/rust-lang/rust/issues/115597.
2023-12-05Auto merge of #118457 - eholk:genfn, r=compiler-errorsbors-4/+64
Add support for `gen fn` This builds on #116447 to add support for `gen fn` functions. For the most part we follow the same approach as desugaring `async fn`, but replacing `Future` with `Iterator` and `async {}` with `gen {}` for the body. The version implemented here uses the return type of a `gen fn` as the yield type. For example: ```rust gen fn count_to_three() -> i32 { yield 1; yield 2; yield 3; } ``` In the future, I think we should experiment with a syntax like `gen fn count_to_three() yield i32 { ... }`, but that can go in another PR. cc `@oli-obk` `@compiler-errors`