about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2024-07-25Work around #96304 by ignoring one test caseAmanieu d'Antras-43/+42
2024-07-25Rollup merge of #128173 - compiler-errors:misused-intrinsics, r=oli-obkMatthias Krüger-47/+0
Remove crashes for misuses of intrinsics All of these do not crash if the feature gate is removed. An ICE due *opting into* the intrinsics feature gate is not a bug that needs to be fixed, but instead a misuse of an internal-only API. See https://github.com/rust-lang/compiler-team/issues/620 The last two issues are already closed anyways, but: Fixes #97501 Fixes #111699 Fixes #101962
2024-07-25Rollup merge of #128172 - compiler-errors:non-self-arg, r=chenyukangMatthias Krüger-12/+55
Don't ICE if HIR and middle types disagree in borrowck error reporting We try to match up the `middle::ty::Ty` and `hir::Ty` types in borrowck error reporting, but due to things like `Self` self type alias, or regular type aliases, these might not match up. Don't ICE. This PR also tries to recover the error by looking up the self type of the impl in case we see `Self`. The diagnostic is frankly quite confusing, but I also didn't really want to look at it because I don't understand the conflict error reporting logic. 🤷 Fixes #121816
2024-07-25Rollup merge of #128171 - compiler-errors:arg-compat, r=oli-obkMatthias Krüger-128/+95
Make sure that args are compatible in `resolve_associated_item` Implements a similar check to the one that we have in projection for GATs (#102488, #123240), where we check that the args of an impl item are compatible before returning it. This is done in `resolve_assoc_item`, which is backing `Instance::resolve`, so this is conceptually generalizing the check from GATs to methods/assoc consts. This is important to make sure that the inliner will only visit and substitute MIR bodies that are compatible w/ their trait definitions. This shouldn't happen in codegen, but there are a few ways to get the inliner to be invoked (via calls to `optimized_mir`) before codegen, namely polymorphization and CTFE. Fixes #121957 Fixes #120792 Fixes #120793 Fixes #121063
2024-07-25Rollup merge of #128138 - folkertdev:asm-option-allowlist, r=lcnrMatthias Krüger-2/+2
`#[naked]`: use an allowlist for allowed options on `asm!` in naked functions tracking issue: https://github.com/rust-lang/rust/issues/90957 this is mostly just a refactor, but using an allowlist (rather than a denylist) for which asm options are allowed in naked functions is a little safer. These options are disallowed because naked functions are effectively global asm, but defined using inline asm.
2024-07-25Rollup merge of #121364 - Urgau:unary_precedence, r=compiler-errorsMatthias Krüger-0/+214
Implement lint against ambiguous negative literals This PR implements a lint against ambiguous negative literals with a literal and method calls right after it. ## `ambiguous_negative_literals` (deny-by-default) The `ambiguous_negative_literals` lint checks for cases that are confusing between a negative literal and a negation that's not part of the literal. ### Example ```rust,compile_fail -1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1 ``` ### Explanation Method calls take precedence over unary precedence. Setting the precedence explicitly makes the code clearer and avoid potential bugs. <details> <summary>Old proposed lint</summary> ## `ambiguous_unary_precedence` (deny-by-default) The `ambiguous_unary_precedence` lint checks for use the negative unary operator with a literal and method calls. ### Example ```rust -1i32.abs(); // equals -1, while `(-1i32).abs()` equals 1 ``` ### Explanation Unary operations take precedence on binary operations and method calls take precedence over unary precedence. Setting the precedence explicitly makes the code clearer and avoid potential bugs. </details> ----- Note: This is a strip down version of https://github.com/rust-lang/rust/pull/117161, without the binary op precedence. Fixes https://github.com/rust-lang/rust/issues/117155 `@rustbot` labels +I-lang-nominated cc `@scottmcm` r? compiler
2024-07-25Auto merge of #128102 - Oneirical:real-testate, r=Kobzolbors-26/+52
Migrate `extern-diff-internal-name`, `extern-multiple-copies` and `extern-multiple-copies2` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: test-various
2024-07-24Don't add crashes for misuses of intrinsicsMichael Goulet-47/+0
2024-07-24Don't ICE if HIR and middle types disagree in borrowck error reportingMichael Goulet-12/+55
2024-07-24Make sure that args are compatible in resolve_associated_itemMichael Goulet-128/+95
2024-07-25Rollup merge of #128160 - compiler-errors:auto, r=jackh726Matthias Krüger-23/+97
Don't ICE when auto trait has assoc ty in old solver Kinda a pointless change to make, but it's observable w/o the feature gate, so let's just fix it. I reintroduced this ICE when I removed the "auto impl" kind from `ImplSource` in #112687. Fixes #117829 Fixes #127746
2024-07-25Rollup merge of #128111 - estebank:no-question, r=fmeaseMatthias Krüger-149/+157
Do not use question as label We don't want to have questions in the diagnostic output. Instead, we use wording that communicates uncertainty, like "might": ``` error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:2:9 | LL | use spam::*; | ^^^^ you might be missing crate `spam` | = help: consider adding `extern crate spam` to use the `spam` crate ```
2024-07-25Rollup merge of #127872 - Oneirical:antestral-traditions, r=jieyouxuMatthias Krüger-50/+63
Migrate `pointer-auth-link-with-c`, `c-dynamic-rlib` and `c-dynamic-dylib` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). Please try: try-job: x86_64-msvc try-job: i686-mingw try-job: aarch64-apple
2024-07-25Rollup merge of #127528 - estebank:ascii-control-chars, r=oli-obkMatthias Krüger-112/+123
Replace ASCII control chars with Unicode Control Pictures Replace ASCII control chars like `CR` with Unicode Control Pictures like `␍`: ``` error: bare CR not allowed in doc-comment --> $DIR/lex-bare-cr-string-literal-doc-comment.rs:3:32 | LL | /// doc comment with bare CR: '␍' | ^ ``` Centralize the checking of unicode char width for the purposes of CLI display in one place. Account for the new replacements. Remove unneeded tracking of "zero-width" unicode chars, as we calculate these in the `SourceMap` as needed now.
2024-07-25Rollup merge of #127054 - compiler-errors:bound-ordering, r=fmeaseMatthias Krüger-32/+104
Reorder trait bound modifiers *after* `for<...>` binder in trait bounds This PR suggests changing the grammar of trait bounds from: ``` [CONSTNESS] [ASYNCNESS] [?] [BINDER] [TRAIT_PATH] const async ? for<'a> Sized ``` to ``` ([BINDER] [CONSTNESS] [ASYNCNESS] | [?]) [TRAIT_PATH] ``` i.e., either ``` ? Sized ``` or ``` for<'a> const async Sized ``` (but not both) ### Why? I think it's strange that the binder applies "more tightly" than the `?` trait polarity. This becomes even weirder when considering that we (or at least, I) want to have `async` trait bounds expressed like: ``` where T: for<'a> async Fn(&'a ()) -> i32, ``` and not: ``` where T: async for<'a> Fn(&'a ()) -> i32, ``` ### Fallout No crates on crater use this syntax, presumably because it's literally useless. This will require modifying the reference grammar, though. ### Alternatives If this is not desirable, then we can alternatively keep parsing `for<'a>` after the `?` but deprecate it with either an FCW (or an immediate hard error), and begin parsing `for<'a>` *before* the `?`.
2024-07-24Don't ICE when auto trait has assoc ty in old solverMichael Goulet-23/+97
2024-07-24Fix ddltool-failed testEsteban Küber-1/+1
2024-07-24Do not use question as labelEsteban Küber-149/+157
We don't want to have questions in the diagnostic output. Instead, we use wording that communicates uncertainty, like "might": ``` error[E0432]: unresolved import `spam` --> $DIR/import-from-missing-star-3.rs:2:9 | LL | use spam::*; | ^^^^ you might be missing crate `spam` | = help: consider adding `extern crate spam` to use the `spam` crate ```
2024-07-24Rollup merge of #128122 - tgross35:missing-fragment-specifier-unconditional, ↵Matthias Krüger-0/+115
r=petrochenkov Mark `missing_fragment_specifier` as `FutureReleaseErrorReportInDeps` We are moving toward forbidding `missing_fragment_specifier` either in edition 2024 or unconditionally. Make a first step toward this by ensuring crates that rely on the old behavior are reported when used as dependencies. Tracking issue: <https://github.com/rust-lang/rust/issues/128143>
2024-07-24Rollup merge of #127717 - gurry:127441-stray-impl-sugg, r=compiler-errorsMatthias Krüger-0/+231
Fix malformed suggestion for repeated maybe unsized bounds Fixes #127441 Now when we encounter something like `foo(a : impl ?Sized + ?Sized)`, instead of suggesting removal of both bounds and leaving `foo(a: impl )` behind, we suggest changing the first bound to `Sized` and removing the second bound, resulting in `foo(a: impl Sized)`. Although the issue was reported for impl trait types, it also occurred with regular param bounds. So if we encounter `foo<T: ?Sized + ?Sized>(a: T)` we now detect that all the bounds are `?Sized` and therefore emit the suggestion to remove the entire predicate `: ?Sized + ?Sized` resulting in `foo<T>(a: T)`. Lastly, if we encounter a situation where some of the bounds are something other than `?Sized`, then we emit separate removal suggestions for each `?Sized` bound. E.g. if we see `foo(a: impl ?Sized + Bar + ?Sized)` or `foo<T: ?Sized + Bar + ?Sized>(a: T)` we emit suggestions such that the user will be left with `foo(a : impl Bar)` or `foo<T: Bar>(a: T)` respectively.
2024-07-24Rollup merge of #122192 - oli-obk:type_of_opaque_for_const_checks, r=lcnrMatthias Krüger-253/+200
Do not try to reveal hidden types when trying to prove auto-traits in the defining scope fixes #99793 this avoids the cycle error by just causing a selection error, which is not fatal. We pessimistically assume that freeze does not hold, which is always a safe assumption.
2024-07-24Mark `missing_fragment_specifier` as `FutureReleaseErrorReportInDeps`Trevor Gross-0/+115
We are moving toward forbidding `missing_fragment_specifier` either in edition 2024 or unconditionally. Make a first step toward this by ensuring crates that rely on the old behavior are reported when used as dependencies. Tracking issue: <https://github.com/rust-lang/rust/issues/128143>
2024-07-24Do not assemble candidates for auto traits of opaque types in their defining ↵Oli Scherer-53/+87
scope
2024-07-24Add regression testsOli Scherer-0/+88
2024-07-24Do not try to reveal hidden types when trying to prove Freeze in the ↵Oli Scherer-252/+28
defining scope
2024-07-24Rollup merge of #128133 - nnethercote:fix-cfg_attr-spans, r=petrochenkovMatthias Krüger-13/+13
Improve spans on evaluated `cfg_attr`s. When converting something like `#![cfg_attr(cond, attr)]` into `#![attr]`, we currently duplicate the `#` token and the `!` token. But weirdly, there is also this comment: // We don't really have a good span to use for the synthesized `[]` // in `#[attr]`, so just use the span of the `#` token. Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the `#` and `!`. This commit does that, thus removing the incorrect comment, and improving the spans on `Group`s in a few proc-macro tests. `@petrochenkov`
2024-07-24Rollup merge of #128120 - compiler-errors:async-fn-name, r=oli-obkMatthias Krüger-2/+24
Gate `AsyncFn*` under `async_closure` feature T-lang has not come to a consensus on the naming of async closure callable bounds, and as part of allowing the async closures RFC merge, we agreed to place `AsyncFn` under the same gate as `async Fn` so that these syntaxes can be evaluated in parallel. See https://github.com/rust-lang/rfcs/pull/3668#issuecomment-2246435537 r? oli-obk
2024-07-24Rollup merge of #127374 - estebank:wrong-generic-args, r=oli-obkMatthias Krüger-162/+164
Tweak "wrong # of generics" suggestions Fix incorrect suggestion, make verbose and change message to make more sense when it isn't a span label.
2024-07-24Rollup merge of #126152 - RalfJung:size_of_val_raw, r=saethlinMatthias Krüger-0/+22
size_of_val_raw: for length 0 this is safe to call For motivation, see https://github.com/rust-lang/unsafe-code-guidelines/issues/465, specifically around [here](https://github.com/rust-lang/unsafe-code-guidelines/issues/465#issuecomment-2136401114). Cc `@rust-lang/opsem`
2024-07-24Add regression testOli Scherer-0/+49
2024-07-24use an allow list for allowed asm options in naked functionsFolkert-2/+2
2024-07-24Auto merge of #126024 - oli-obk:candidate_key_caching_is_unsound_yay, r=lcnrbors-1/+4
Do not use global caches if opaque types can be defined fixes #119272 r? `@lcnr` This is certainly a crude way to make the cache sound wrt opaque types, but since perf lets us get away with this, let's do it in the old solver and let the new solver fix this correctly once and for all. cc https://github.com/rust-lang/rust/pull/122192#issuecomment-2149252655
2024-07-24Improve spans on evaluated `cfg_attr`s.Nicholas Nethercote-13/+13
When converting something like `#![cfg_attr(cond, attr)]` into `#![attr]`, we currently duplicate the `#` token and the `!` token. But weirdly, there is also this comment: // We don't really have a good span to use for the synthesized `[]` // in `#[attr]`, so just use the span of the `#` token. Maybe that comment used to be true? But now it is false: we can duplicate the existing delimiters (and their spans and spacing), much like we do for the `#` and `!`. This commit does that, thus removing the incorrect comment, and improving the spans on `Group`s in a few proc-macro tests.
2024-07-24Don't use global caches if opaques can be definedOli Scherer-1/+4
2024-07-24Auto merge of #127524 - oli-obk:feed_item_attrs2, r=petrochenkovbors-9/+10
Make ast `MutVisitor` have the same method name and style as `Visitor` It doesn't map 100% because some `MutVisitor` methods can filter or even expand to multiple items, but consistency seems nicer. tracking issue: https://github.com/rust-lang/rust/issues/127615
2024-07-24Rollup merge of #127481 - a1phyr:pattern_gat, r=AmanieuMatthias Krüger-30/+33
Remove generic lifetime parameter of trait `Pattern` Use a GAT for `Searcher` associated type because this trait is always implemented for every lifetime anyway. cc #27721
2024-07-23Gate AsyncFn* under async_closure featureMichael Goulet-2/+24
2024-07-23rewrite extern-multiple-copies2 to rmakeOneirical-15/+22
2024-07-23Rollup merge of #128082 - compiler-errors:closure-cap, r=estebankMatthias Krüger-0/+6
Note closure captures when reporting cast to fn ptr failed Fixes #128078 We already had logic to point out a closure having captures when that's possibly the source of a coercion error to `fn()`, but we weren't reporting it during an explicit `as` cast.
2024-07-23Rollup merge of #127990 - Oneirical:ii-the-high-priestest, r=jieyouxuMatthias Krüger-30/+64
Migrate `lto-linkage-used-attr`, `no-duplicate-libs` and `pgo-gen-no-imp-symbols` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html). try-job: x86_64-msvc try-job: aarch64-apple try-job: armhf-gnu try-job: test-various try-job: x86_64-gnu-llvm-18
2024-07-23Rollup merge of #126898 - GuillaumeGomez:migrate-run-make-link-framework, ↵Matthias Krüger-23/+38
r=Kobzol Migrate `run-make/link-framework` to `rmake.rs` Part of https://github.com/rust-lang/rust/issues/121876. r? ``@Kobzol`` try-job: x86_64-apple-1
2024-07-23Rollup merge of #125886 - GuillaumeGomez:migrate-run-make-issue-15460, ↵Matthias Krüger-7/+14
r=jieyouxu Migrate run make issue 15460 Part of https://github.com/rust-lang/rust/issues/121876. r? `@jieyouxu` try-job: x86_64-msvc try-job: aarch64-apple try-job: x86_64-gnu-llvm-18
2024-07-23rewrite extern-multiple-copies to rmakeOneirical-9/+17
2024-07-23rewrite extern-diff-internal-name to rmakeOneirical-6/+17
2024-07-23rewrite c-dynamic-dylib to rmakeOneirical-22/+19
2024-07-23Auto merge of #128093 - matthiaskrgr:rollup-1snye4b, r=matthiaskrgrbors-7/+165
Rollup of 6 pull requests Successful merges: - #125834 (treat `&raw (const|mut) UNSAFE_STATIC` implied deref as safe) - #127962 (Cleanup compiletest dylib name calculation) - #128049 (Reword E0626 to mention static coroutine, add structured suggestion for adding `static`) - #128067 (Get rid of `can_eq_shallow`) - #128076 (Get rid of `InferCtxtExt` from `error_reporting::traits`) - #128089 (std: Unsafe-wrap actually-universal platform code) r? `@ghost` `@rustbot` modify labels: rollup
2024-07-23Rollup merge of #128049 - compiler-errors:E0626, r=petrochenkovMatthias Krüger-0/+64
Reword E0626 to mention static coroutine, add structured suggestion for adding `static` Not certain how to make the example feel less artificial. 🤷 My main point though is that we should probably emphasize that the first solution to making a coroutine allow a borrow across an await is making it `static`. Also adds a structured suggestion.
2024-07-23Rollup merge of #125834 - ↵Matthias Krüger-7/+101
workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors treat `&raw (const|mut) UNSAFE_STATIC` implied deref as safe Fixes rust-lang/rust#125833 As reported in that and related issues, `static mut STATIC_MUT: T` is very often used in embedded code, and is in many ways equivalent to `static STATIC_CELL: SyncUnsafeCell<T>`. The Rust expression of `&raw mut STATIC_MUT` and `SyncUnsafeCell::get(&STATIC_CELL)` are approximately equal, and both evaluate to `*mut T`. The library function is safe because it has *declared itself* to be safe. However, the raw ref operator is unsafe because all uses of `static mut` are considered unsafe, even though the static's value is not used by this expression (unlike, for example, `&STATIC_MUT`). We can fix this unnatural difference by simply adding the proper exclusion for the safety check inside the THIR unsafeck, so that we do not declare it unsafe if it is not. While the primary concern here is `static mut`, this change is made for all instances of an "unsafe static", which includes a static declared inside `extern "abi" {}`. Hypothetically, we could go as far as generalizing this to all instances of `&raw (const|mut) *ptr`, but today we do not, as we have not actually considered the range of possible expressions that use a similar encoding. We do not even extend this to thread-local equivalents, because they have less clear semantics.
2024-07-23Rename `tests/run-make/issue-15460` into ↵Guillaume Gomez-0/+2
`tests/run-make/link-native-static-lib-to-dylib`
2024-07-23Migrate `run-make/issue-15460` to `rmake.rs`Guillaume Gomez-7/+12