about summary refs log tree commit diff
path: root/tests
AgeCommit message (Collapse)AuthorLines
2023-07-27Auto merge of #108980 - Enselic:println-and-broken-pipe, r=workingjubileebors-0/+47
Regression test `println!()` panic message on `ErrorKind::BrokenPipe` No existing test (that I could find) failed if the `panic!()` of the `println!()` family of functions was removed, or if its message was changed: https://github.com/rust-lang/rust/blob/104f4300cfddbd956e32820ef202a732f06ec848/library/std/src/io/stdio.rs#L1007-L1009 So add such a test. This is in preparation of adding a hint about the existence of [`unix_sigpipe`](https://github.com/rust-lang/rust/issues/97889) if that is the reason for the panic. Even if we don't end up adding a hint, this is still a sensible test to have, I think. `@rustbot` label +A-testsuite +A-io +T-libs +O-unix
2023-07-27Rollup merge of #114139 - Urgau:make-print-with-path-unstable, r=jackh726Jubilee-4/+17
Make `--print` with path unstable https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable. [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/238009-t-compiler.2Fmeetings/topic/.5Bweekly.5D.202023-07-27/near/379199738) cc `@dtolnay`
2023-07-27Rollup merge of #114122 - Enselic:hello-build-pass, r=petrochenkovJubilee-1/+1
tests/ui/hello_world/main.rs: Remove FIXME (#62277) The purpose of the test is to make sure that compiling hello world produces no compiler output. To properly test that, we need to run the entire compiler pipeline. We don't want the test to pass if codegen accidentally starts writing to stdout. So keep it as build-pass. Part of #62277
2023-07-27Make `--print KIND=PATH` unstableUrgau-4/+17
https://github.com/rust-lang/rust/pull/113780 should have gone through an MCP+FCP but wasn't, but instead of reverting the original PR, this PR just make that new option unstable.
2023-07-27Auto merge of #113374 - GuillaumeGomez:private-to-public-path, ↵bors-0/+212
r=notriddle,fmease [rustdoc] If re-export is private, get the next item until a public one is found or expose the private item directly Fixes #81141. If we have: ```rust use Private as Something; pub fn foo() -> Something {} ``` Then `Something` will be replaced by `Private`. r? `@notriddle`
2023-07-27Rollup merge of #114123 - oli-obk:tait_wtf, r=WaffleLapkinGuillaume Gomez-0/+16
Turns out opaque types can have hidden types registered during mir validation See the newly added test's documentation for an explanation. fixes #114121
2023-07-27Rollup merge of #114117 - compiler-errors:return-to-uniq, r=lcnrGuillaume Gomez-1/+33
Restore region uniquification in the new solver 🎉 All of the bugs that were "due" to uniquification have been settled via other means (e.g. bidirectional alias-relate, param-env incompleteness, etc). Firstly, revert the functional changes in #110180. 😸 Secondly, we need to ignore regions when considering if a goal has changed (the "has_changed" boolean returned from `evaluate_goal`) -- otherwise, because we're doing region uniquification, we may perpetually consider a goal to be changed. See the UI test I committed for an explanation.
2023-07-27Rollup merge of #114088 - oli-obk:syn, r=davidtwcoGuillaume Gomez-178/+185
Bump syn dependency r? `@davidtwco` because this affects diagnostics derive diagnostics (yes this sentence is grammatically correct)
2023-07-27Rollup merge of #114059 - fmease:rustdoc-fix-x-crate-impl-sized, ↵Guillaume Gomez-2/+50
r=GuillaumeGomez rustdoc: fix cross-crate `impl Sized` & `impl ?Sized` Previously, cross-crate impl-Trait (APIT, RPIT, etc.) that only consists of a single `Sized` bound (modulo outlives-bounds) and ones that are `?Sized` were incorrectly rendered. To give you a taste (before vs. after): ```diff - fn sized(x: impl ) -> impl + fn sized(x: impl Sized) -> impl Sized - fn sized_outlives<'a>(x: impl 'a) -> impl 'a + fn sized_outlives<'a>(x: impl Sized + 'a) -> impl Sized + 'a - fn maybe_sized(x: &impl ) -> &impl + fn maybe_sized(x: &impl ?Sized) -> &impl ?Sized - fn debug_maybe_sized(x: &impl Debug) -> &impl ?Sized + Debug + fn debug_maybe_sized(x: &(impl Debug + ?Sized)) -> &(impl Debug + ?Sized) ``` Moreover, we now surround impl-Trait that has multiple bounds with parentheses if they're the pointee of a reference or raw pointer type. This affects both local and cross-crate docs. The current output isn't correct (rustc would emit the error *ambiguous `+` in a type* if we fed the rendered code back to it). --- Best reviewed commit by commit :) `@rustbot` label A-cross-crate-reexports
2023-07-27Turns out opaque types can have hidden types registered during mir validationOli Scherer-0/+16
2023-07-27tests/ui/hello_world/main.rs: Remove FIXMEMartin Nordholts-1/+1
The purpose of the test is to make sure that compiling hello world produces no compiler output. To properly test that, we need to run the entire compiler pipeline. We don't want the test to pass if codegen accidentally starts writing to stdout. So keep it as build-pass.
2023-07-27Consider a goal as NOT changed if its response is identity modulo regionsMichael Goulet-1/+33
2023-07-27Auto merge of #113708 - rcvalle:rust-cfi-fix-100778, r=compiler-errorsbors-0/+59
CFI: Fix ICE: encode_const: unexpected type [usize Fixes #100778 and #113366, and complements #106547 by adding support for encoding const parameters.
2023-07-26Auto merge of #113843 - wesleywiser:replace_rustc_apfloat, r=pnkfelixbors-0/+39
Replace in-tree `rustc_apfloat` with the new version of the crate Replace the in-tree version of `rustc_apfloat` with the new version of the crate which has been correctly licensed. The new crate incorporates upstream changes from LLVM since the original port was done including many correctness fixes and has been extensively fuzz tested to validate correctness. Fixes #100233 Fixes #102403 Fixes #113407 Fixes #113409 Fixes #55993 Fixes #93224 Closes #93225 Closes #109573
2023-07-26Auto merge of #114103 - matthiaskrgr:rollup-01m6l2w, r=matthiaskrgrbors-2/+2
Rollup of 7 pull requests Successful merges: - #101994 (rand: freebsd update, using getrandom.) - #113930 (Add Param and Bound ty to SMIR) - #113942 (Squelch a noisy rustc_expand unittest) - #113996 (Define CMAKE_SYSTEM_NAME on a cross build targeting DragonFly.) - #114070 (Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy) - #114073 (Remove -Z diagnostic-width) - #114090 (compiletest: remove ci-specific remap-path-prefix) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-26Rollup merge of #114070 - blyxyas:iter_mut_symbol, r=oli-obkMatthias Krüger-2/+2
Add `sym::iter_mut` + `sym::as_mut_ptr` for Clippy We currently have `sym::iter` and `sym::iter_repeat`, this PR adds `sym::iter_mut` as it's useful for https://github.com/rust-lang/rust-clippy/pull/11038 and another Clippy lint, it also adds `sym::as_mut_ptr` as it's useful for https://github.com/rust-lang/rust-clippy/pull/10962.
2023-07-26Auto merge of #114012 - GuillaumeGomez:fix-113982, r=notriddlebors-0/+22
Fix missing attribute merge on glob foreign re-exports Fixes https://github.com/rust-lang/rust/issues/113982. The attributes were not merged with the import's in case of glob re-export of foreign items. r? `@notriddle`
2023-07-26Add tests for #102403 and #113407Ralf Jung-0/+24
2023-07-26Add test case for #109567yukang-0/+15
2023-07-26Auto merge of #113457 - davidtwco:lint-ctypes-issue-113436, r=oli-obkbors-0/+97
lint/ctypes: fix `()` return type checks Fixes #113436. `()` is normally FFI-unsafe, but is FFI-safe when used as a return type. It is also desirable that a transparent newtype for `()` is FFI-safe when used as a return type. In order to support this, when a type was deemed FFI-unsafe, because of a `()` type, and was used in return type - then the type was considered FFI-safe. However, this was the wrong approach - it didn't check that the `()` was part of a transparent newtype! The consequence of this is that the presence of a `()` type in a more complex return type would make it the entire type be considered safe (as long as the `()` type was the first that the lint found) - which is obviously incorrect. Instead, this logic is removed, and after [consultation with t-lang](https://github.com/rust-lang/rust/issues/113436#issuecomment-1640756721), I've fixed the bugs and inconsistencies and made `()` FFI-safe within types. I also refactor a function, but that's not too exciting.
2023-07-26Fix regression for private in publicGuillaume Gomez-0/+14
2023-07-26Regression test `println!()` panic message on `ErrorKind::BrokenPipe`Martin Nordholts-0/+47
No existing test failed if the [`panic!()`][1] of the `println!()` family of functions was removed, or if its message was changed. So add such a test. [1] https://github.com/rust-lang/rust/blob/104f4300cfddbd956e32820ef202a732f06ec848/library/std/src/io/stdio.rs#L1007-L1009
2023-07-26Bump syn dependencyOli Scherer-98/+106
2023-07-26Bump syn now that it doesn't affect diagnostics anymoreOli Scherer-90/+89
2023-07-26Auto merge of #113893 - mdibaiee:type-name-spill-flag, r=compiler-errorsbors-28/+14
new unstable option: -Zwrite-long-types-to-disk This option guards the logic of writing long type names in files and instead using short forms in error messages in rustc_middle/ty/error behind a flag. The main motivation for this change is to disable this behaviour when running ui tests. This logic can be triggered by running tests in a directory that has a long enough path, e.g. /my/very-long-path/where/rust-codebase/exists/ This means ui tests can fail depending on how long the path to their file is. Some ui tests actually rely on this behaviour for their assertions, so for those we enable the flag manually.
2023-07-26rustdoc: fix cross-crate impl-SizedLeón Orell Valerian Liehr-2/+50
2023-07-25Add `sym::iter_mut` + `sym::as_mut_ptr`blyxyas-2/+2
2023-07-25Rollup merge of #113661 - oli-obk:tait_wtf, r=lcnrMatthias Krüger-2/+73
Double check that hidden types match the expected hidden type Fixes https://github.com/rust-lang/rust/issues/113278 specifically, but I left a TODO for where we should also add some hardening. It feels a bit like papering over the issue, but at least this way we don't get unsoundness, but just surprising errors. Errors will be improved and given spans before this PR lands. r? `@compiler-errors` `@lcnr`
2023-07-25Rollup merge of #113578 - compiler-errors:uncallable-sig, r=b-naberMatthias Krüger-0/+17
Don't say that a type is uncallable if its fn signature has errors in it This is fallout from #106309, where we don't consider param-env candidates that reference errors because they unify with everything. This means, however, that we don't consider an APIT like `impl Fn(MissingType)` isn't considered to implement `Fn`, for example. We can double-check that with a weaker heuristic [`extract_callable_info`](https://doc.rust-lang.org/nightly/nightly-rustc/rustc_hir_typeck/fn_ctxt/struct.FnCtxt.html#method.extract_callable_info), and suppress the knock-down error using that. Fixes #113566
2023-07-25Rollup merge of #112995 - strottos:ref-clone-suggestions, r=fee1-deadMatthias Krüger-1/+330
Check for `<&NotClone as Clone>::clone()` calls and suggest to add Clone trait appropriately Added recursive checking back up the HIR to see if a `Clone` suggestion would be helpful. Addresses https://github.com/rust-lang/rust/issues/112857 Largely based on: https://github.com/rust-lang/rust/pull/112977
2023-07-25Auto merge of #114063 - matthiaskrgr:rollup-c90czu6, r=matthiaskrgrbors-3/+155
Rollup of 7 pull requests Successful merges: - #114008 (coverage: Obtain the `__llvm_covfun` section name outside a per-function loop) - #114014 (builtin_macros: expect raw strings too) - #114043 (docs(LazyLock): add example pass local LazyLock variable to struct) - #114051 (Add regression test for invalid "unused const" in method) - #114052 (Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some cases) - #114058 (Add help for crate arg when crate name is invalid) - #114060 (abi: unsized field in union - assert to delay bug ) r? `@ghost` `@rustbot` modify labels: rollup
2023-07-25Rollup merge of #114060 - davidtwco:issue-113279, r=wesleywiserMatthias Krüger-0/+43
abi: unsized field in union - assert to delay bug Fixes #113279. > Unions cannot have unsized fields, and as such, layout computation for unions asserts that each union field is sized (as this would normally have halted compilation earlier). > > However, if a generator ends up with an unsized local - a circumstance in which an error will always have been emitted earlier, for example, if attempting to dereference a `&str` - then the generator transform will produce a union with an unsized field. > > Since https://github.com/rust-lang/rust/pull/110107, later passes will be run, such as constant propagation, and can attempt layout computation on the generator, which will result in layout computation of `str` in the context of it being a field of a union - and so the aforementioned assertion would cause an ICE. > > It didn't seem appropriate to try and detect this case in the MIR body and skip this specific pass; tainting the MIR body or delaying a bug from the generator transform (or elsewhere) wouldn't prevent this either (as neither would prevent the later pass from running); and tainting when the deref of `&str` is reported, if that's possible, would unnecessarily prevent potential other errors from being reported later in compilation, and is very tailored to this specific case of getting a unsized type in a generator. > > Given that this circumstance can only happen when an error should have already been reported, the correct fix appears to be just changing the assert to a delayed bug. This will still assert if there is some circumstance where this occurs and no error has been reported, but it won't crash the compiler in this instance. While debugging this, I noticed a translation ICE in a delayed bug, so I fixed that too: > During borrowck, the `MultiSpan` from a buffered diagnostic is cloned and used to emit a delayed bug indicating a diagnostic was buffered - when the buffered diagnostic is translated, then the cloned `MultiSpan` may contain labels which can only render with the diagnostic's arguments, but the delayed bug being emitted won't have those arguments. Adds a function which clones `MultiSpan` without also cloning the contained labels, and use this function when creating the buffered diagnostic delayed bug.
2023-07-25Rollup merge of #114058 - chenyukang:yukang-fix-113981-crate-arg, ↵Matthias Krüger-0/+8
r=fmease,oli-obk Add help for crate arg when crate name is invalid Fixes #113981
2023-07-25Rollup merge of #114052 - clubby789:suggest-option-asref, r=WaffleLapkinMatthias Krüger-3/+51
Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some cases Fixes #114050 When we have an expr available that produces the type expectation, we can suggest appending `.as_ref()` to the span, instead of cloning the expr producing the mismatch
2023-07-25Rollup merge of #114051 - Enselic:const-local-var, r=cjgillotMatthias Krüger-0/+23
Add regression test for invalid "unused const" in method The warning can be reproduced with 1.63 but not with 1.64. $ rustc +1.63 tests/ui/lint/unused/const-local-var.rs warning: constant `F` is never used --> tests/ui/lint/unused/const-local-var.rs:14:9 | 14 | const F: i32 = 2; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default $ rustc +1.64 tests/ui/lint/unused/const-local-var.rs Add a regression test to prevent the problem from re-appearing. Closes #69016
2023-07-25Rollup merge of #114014 - davidtwco:issue-114010-env-rawstr, r=cjgillotMatthias Krüger-0/+30
builtin_macros: expect raw strings too Fixes #114010. `expr_to_string` allows raw strings through so this code should be expected to handle those.
2023-07-25Auto merge of #113393 - compiler-errors:next-solver-unsize-rhs, r=lcnrbors-0/+25
Normalize the RHS of an `Unsize` goal in the new solver `Unsize` goals are... tricky. Not only do they structurally match on their self type, but they're also structural on their other type parameter. I'm pretty certain that it is both incomplete and also just plain undesirable to not consider normalizing the RHS of an unsize goal. More practically, I'd like for this code to work: ```rust trait A {} trait B: A {} impl A for usize {} impl B for usize {} trait Mirror { type Assoc: ?Sized; } impl<T: ?Sized> Mirror for T { type Assoc = T; } fn main() { // usize: Unsize<dyn B> let x = Box::new(1usize) as Box<<dyn B as Mirror>::Assoc>; // dyn A: Unsize<dyn B> let y = x as Box<<dyn A as Mirror>::Assoc>; } ``` --- In order to achieve this, we add `EvalCtxt::normalize_non_self_ty` (naming modulo bikeshedding), which *must* be used for all non-self type arguments that are structurally matched in candidate assembly. Currently this is only necessary for `Unsize`'s argument, but I could see future traits requiring this (hopefully rarely) in the future. It uses `repeat_while_none` to limit infinite looping, and normalizes the self type until it is no longer an alias. Also, we need to fix feature gate detection for `trait_upcasting` and `unsized_tuple_coercion` when HIR typeck has unnormalized types. We can do that by checking the `ImplSource` returned by selection, which necessitates adding a new impl source for tuple upcasting.
2023-07-26Add help for crate arg when crate name is invalidyukang-0/+8
2023-07-25Make sure to detect trait upcasting coercion even after normalizationMichael Goulet-0/+4
2023-07-25Normalize the RHS of an unsize goalMichael Goulet-0/+21
2023-07-25abi: unsized field in union - assert to delay bugDavid Wood-0/+43
Unions cannot have unsized fields, and as such, layout computation for unions asserts that each union field is sized (as this would normally have halted compilation earlier). However, if a generator ends up with an unsized local - a circumstance in which an error will always have been emitted earlier, for example, if attempting to dereference a `&str` - then the generator transform will produce a union with an unsized field. Since #110107, later passes will be run, such as constant propagation, and can attempt layout computation on the generator, which will result in layout computation of `str` in the context of it being a field of a union - and so the aforementioned assertion would cause an ICE. It didn't seem appropriate to try and detect this case in the MIR body and skip this specific pass; tainting the MIR body or delaying a bug from the generator transform (or elsewhere) wouldn't prevent this either (as neither would prevent the later pass from running); and tainting when the deref of `&str` is reported, if that's possible, would unnecessarily prevent potential other errors from being reported later in compilation, and is very tailored to this specific case of getting a unsized type in a generator. Given that this circumstance can only happen when an error should have already been reported, the correct fix appears to be just changing the assert to a delayed bug. This will still assert if there is some circumstance where this occurs and no error has been reported, but it won't crash the compiler in this instance. Signed-off-by: David Wood <david@davidtw.co>
2023-07-25Auto merge of #114011 - RalfJung:place-projection, r=oli-obkbors-46/+106
interpret: Unify projections for MPlaceTy, PlaceTy, OpTy For ~forever, we didn't really have proper shared code for handling projections into those three types. This is mostly because `PlaceTy` projections require `&mut self`: they might have to `force_allocate` to be able to represent a project part-way into a local. This PR finally fixes that, by enhancing `Place::Local` with an `offset` so that such an optimized place can point into a part of a place without having requiring an in-memory representation. If we later write to that place, we will still do `force_allocate` -- for now we don't have an optimized path in `write_immediate` that would avoid allocation for partial overwrites of immediately stored locals. But in `write_immediate` we have `&mut self` so at least this no longer pollutes all our type signatures. (Ironically, I seem to distantly remember that many years ago, `Place::Local` *did* have an `offset`, and I removed it to simplify things. I guess I didn't realize why it was so useful... I am also not sure if this was actually used to achieve place projection on `&self` back then.) The `offset` had type `Option<Size>`, where `None` represent "no projection was applied". This is needed because locals *can* be unsized (when they are arguments) but `Place::Local` cannot store metadata: if the offset is `None`, this refers to the entire local, so we can use the metadata of the local itself (which must be indirect); if a projection gets applied, since the local is indirect, it will turn into a `Place::Ptr`. (Note that even for indirect locals we can have `Place::Local`: when the local appears in MIR, we always start with `Place::Local`, and only check `frame.locals` later. We could eagerly normalize to `Place::Ptr` but I don't think that would actually simplify things much.) Having done all that, we can finally properly abstract projections: we have a new `Projectable` trait that has the basic methods required for projecting, and then all projection methods are implemented for anything that implements that trait. We can even implement it for `ImmTy`! (Not that we need that, but it seems neat.) The visitor can be greatly simplified; it doesn't need its own trait any more but it can use the `Projectable` trait. We also don't need the separate `Mut` visitor any more; that was required only to reflect that projections on `PlaceTy` needed `&mut self`. It is possible that there are some more `&mut self` that can now become `&self`... I guess we'll notice that over time. r? `@oli-obk`
2023-07-25Suggest `{Option,Result}::as_ref()` instead of `cloned()` in some casesclubby789-3/+51
2023-07-25bless moreRalf Jung-7/+20
2023-07-25interpret: refactor projection code to work on a common trait, and use that ↵Ralf Jung-38/+85
for visitors
2023-07-25Auto merge of #113476 - fee1-dead-contrib:c-str-lit, r=petrochenkovbors-88/+42
Reimplement C-str literals This reverts #113334, cc `@fmease.` While converting lexer tokens to ast Tokens in `rustc_parse`, we check the edition of the span of the token. If the edition < 2021, we split the token into two, one being the identifier and other being the str literal.
2023-07-25write-long-types-to-disk: update testsMahdi Dibaiee-58/+38
2023-07-25Add regression test for invalid unused const in methodMartin Nordholts-0/+23
The warning can be reproduced with 1.63 but not with 1.64. $ rustc +1.63 tests/ui/lint/unused/const-local-var.rs warning: constant `F` is never used --> tests/ui/lint/unused/const-local-var.rs:14:9 | 14 | const F: i32 = 2; | ^^^^^^^^^^^^^^^^^ | = note: `#[warn(dead_code)]` on by default $ rustc +1.64 tests/ui/lint/unused/const-local-var.rs Add a regression test to prevent the problem from re-appearing.
2023-07-25builtin_macros: raw str in diagnostic outputDavid Wood-3/+16
If a raw string was used in the `env!` invocation, then it should also be shown in the diagnostic messages as a raw string. Signed-off-by: David Wood <david@davidtw.co>
2023-07-25Added recursive checking back up to see if a `Clone` suggestion would be ↵Steven Trotter-1/+330
helpful.