about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-08-02Rollup merge of #86176 - nbdd0121:explicit-generic-args, r=jackh726Cameron Steffen-0/+49
Implement a `explicit_generic_args_with_impl_trait` feature gate Implements #83701 When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait` So code like this will be accepted: ```rust #![feature(explicit_generic_args_with_impl_trait)] fn foo<T: ?Sized>(_f: impl AsRef<T>) {} fn main() { foo::<str>("".to_string()); } ```
2021-08-02Auto merge of #87248 - RalfJung:ctfe-partial-overwrite, r=oli-obkbors-0/+35
CTFE: throw unsupported error when partially overwriting a pointer Currently, during CTFE, when a write to memory would overwrite parts of a pointer, we make the remaining parts of that pointer "uninitialized". This is probably not what users expect, so if this ever happens they will be quite confused about why some of the data just vanishes for seemingly no good reason. So I propose we change this to abort CTFE when that happens, to at last avoid silently doing the wrong thing. Cc https://github.com/rust-lang/rust/issues/87184 Our CTFE test suite still seems to pass. However, we should probably crater this, and I want to do some tests with Miri as well.
2021-08-02Better message for invalid keyword placement in fnAlexis Bourget-3/+150
After this commit, `unsafe async fn ...` now suggests the `async unsafe` fix instead of misunderstanding the issue. This is not perfect for repeated keywords (`const async const`) and for keywords that are misplaced after `extern "some abi"` because of the way `check_fn_font_matter` works, but changing it breaks so many tests and diagnostics it has been judged too high a cost for this PR.
2021-08-02Auto merge of #87535 - lf-:authors, r=Mark-Simulacrumbors-2/+0
rfc3052 followup: Remove authors field from Cargo manifests Since RFC 3052 soft deprecated the authors field, hiding it from crates.io, docs.rs, and making Cargo not add it by default, and it is not generally up to date/useful information for contributors, we may as well remove it from crates in this repo.
2021-08-02Implement a `explicit_generic_args_with_impl_trait` feature gateGary Guo-0/+49
When this gate is enabled, explicit generic arguments can be specified even if `impl Trait` is used in argument position. Generic arguments can only be specified for explicit generic parameters but not for the synthetic type parameters from `impl Trait`
2021-08-02Rollup merge of #86183 - inquisitivecrystal:env-nul, r=m-ou-seYuki Okushi-0/+10
Change environment variable getters to error recoverably This PR changes the standard library environment variable getter functions to error recoverably (i.e. not panic) when given an invalid value. On some platforms, it is invalid for environment variable names to contain `'\0'` or `'='`, or for their values to contain `'\0'`. Currently, the standard library panics when manipulating environment variables with names or values that violate these invariants. However, this behavior doesn't make a lot of sense, at least in the case of getters. If the environment variable is missing, the standard library just returns an error value, rather than panicking. It doesn't make sense to treat the case where the variable is invalid any differently from that. See the [internals thread](https://internals.rust-lang.org/t/why-should-std-var-panic/14847) for discussion. Thus, this PR changes the functions to error recoverably in this case as well. If desired, I could change the functions that manipulate environment variables in other ways as well. I didn't do that here because it wasn't entirely clear what to change them to. Should they error silently or do something else? If someone tells me how to change them, I'm happy to implement the changes. This fixes #86082, an ICE that arises from the current behavior. It also adds a regression test to make sure the ICE does not occur again in the future. `@rustbot` label +T-libs r? `@joshtriplett`
2021-08-01Auto merge of #81825 - voidc:pidfd, r=joshtriplettbors-7/+80
Add Linux-specific pidfd process extensions (take 2) Continuation of #77168. I addressed the following concerns from the original PR: - make `CommandExt` and `ChildExt` sealed traits - wrap file descriptors in `PidFd` struct representing ownership over the fd - add `take_pidfd` to take the fd out of `Child` - close fd when dropped Tracking Issue: #82971
2021-08-01Auto merge of #87546 - rusticstuff:issue87450-take-two, r=davidtwcobors-0/+43
Bail on any found recursion when expanding opaque types Fixes #87450. More of a bandaid because it does not fix the exponential complexity of the type folding used for opaque type expansion.
2021-08-01Check whether clone3 syscall exists in pidfd testDominik Stolz-1/+19
2021-08-01Do not call getpid wrapper after fork in testsDominik Stolz-7/+35
The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent. However, libc::getpid() returns the wrong value. Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls. The cached value is only updated when the wrapper functions for fork or clone are called. In PR #81825 we switch to directly using the clone3 syscall. Thus, the cache is not updated and getpid returns the PID of the parent. source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES
2021-07-312229: Handle MutBorrow/UniqueImmBorrow betterAman Arora-16/+16
We only want to use UniqueImmBorrow when the capture place is truncated and we drop Deref of a MutRef. r? @nikomatsakis
2021-07-31Auto merge of #87662 - FabianWolff:rb-string, r=estebankbors-0/+30
Suggest `br` if the unknown string prefix `rb` is found Currently, for the following code: ```rust fn main() { rb"abc"; } ``` we issue the following suggestion: ``` help: consider inserting whitespace here | 2 | rb "abc"; | -- ``` With my changes (only in edition 2021, where unknown prefixes became an error), I get: ``` help: use `br` for a raw byte string | 2 | br"abc"; | ^^ ```
2021-07-31Provide a suggestion when trying to destructure a `Vec` as a sliceFabian Wolff-0/+52
2021-07-31Tweak opaque type mismatch errorEsteban Küber-57/+71
2021-07-31Require parentheses to avoid confusions around labeled break and loop ↵Fabian Wolff-17/+65
expressions
2021-07-31Auto merge of #87610 - Aaron1011:bump-llvm-bugfix, r=cuviperbors-6/+2
Bump LLVM for RegAllocFast bugfix Fixes #83854 cc `@cuviper`
2021-07-31Fix obtain-borrowck failure on MSVC.Vytautas Astrauskas-1/+7
2021-07-31Point at unmet explicit lifetime obligation boundEsteban Küber-27/+140
2021-07-31Fix ICE in `improper_ctypes_definitions` lint with all-ZST transparent typesFabian Wolff-0/+28
2021-07-31Auto merge of #87607 - JohnTitor:help-to-unused-must-use-op, r=estebankbors-142/+316
Add a hint that the expressions produce a value Fixes #85913 The second commit is semi-_unrelated_ but it allows us to run the related tests just on `src/test/ui/lint`.
2021-07-31Suggest `br` if the unknown string prefix `rb` is foundFabian Wolff-0/+30
2021-07-31Fix invalid suggestions for non-ASCII characters in byte constantsFabian Wolff-12/+69
2021-07-31add a testRalf Jung-0/+35
2021-07-31Auto merge of #86264 - crlf0710:trait_upcasting_part1, r=nikomatsakisbors-7/+423
Trait upcasting coercion (part1) This revives the first part of earlier PR #60900 . It's not very clear to me which parts of that pr was design decisions, so i decide to cut it into pieces and land them incrementally. This allows more eyes on the details. This is the first part, it adds feature gates, adds feature gates tests, and implemented the unsize conversion part. (I hope i have dealt with the `ExistentialTraitRef` values correctly...) The next part will be implementing the pointer casting.
2021-07-31Add more tests to cover more corner cases of type-checking.Charles Lew-0/+342
2021-07-30Auto merge of #86754 - estebank:use-multispans-more, r=varkorbors-333/+473
Use `multipart_suggestions` more Built on top of #86532
2021-07-31Apply review suggestionYuki Okushi-60/+150
2021-07-31Move the `unused` dir to `lint`s subdirYuki Okushi-0/+0
2021-07-31Add a hint that the expressions produce a valueYuki Okushi-29/+113
2021-07-31Fix a parser ICE on invalid `fn` bodyYuki Okushi-0/+28
2021-07-30Auto merge of #87640 - JohnTitor:rollup-yq24nq5, r=JohnTitorbors-40/+310
Rollup of 9 pull requests Successful merges: - #86072 (Cross compiling rustc_llvm on Darwin requires zlib.) - #87385 (Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default) - #87547 (Add missing examples for NonNull) - #87557 (Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic) - #87559 (Tweak borrowing suggestion in `for` loop) - #87596 (Add warning when whitespace is not skipped after an escaped newline) - #87606 (Add some TAIT-related regression tests) - #87609 (Add docs about performance and `Iterator::map` to `[T; N]::map`) - #87616 (Fix missing word in rustdoc book) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-31Rollup merge of #87606 - JohnTitor:tait-tests, r=oli-obkYuki Okushi-0/+53
Add some TAIT-related regression tests Closes #74280, closes #77179. r? ``@oli-obk``
2021-07-31Rollup merge of #87559 - estebank:consider-borrowing, r=oli-obkYuki Okushi-14/+37
Tweak borrowing suggestion in `for` loop
2021-07-31Rollup merge of #87557 - rylev:fix-invalid-prelude-collision-error, ↵Yuki Okushi-0/+108
r=nikomatsakis Fix issue with autofix for ambiguous associated function from Rust 2021 prelude when struct is generic Fixes #86940 The test cases and associated issue should make it clear what specifically this is meant to fix. The fix is slightly hacky in that we check against the literal source code of the call site for the presence of `<` in order to determine if the user has included the generics for the struct (meaning we don't need to include them for them). r? ``@nikomatsakis``
2021-07-31Rollup merge of #87385 - Aaron1011:final-enable-semi, r=petrochenkovYuki Okushi-26/+112
Make `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` warn by default This PR makes the `SEMICOLON_IN_EXPRESSIONS_FROM_MACROS` lint warn by default. To avoid showing a large number of un-actionable warnings to users, we only enable the lint for macros defined in the same crate. This ensures that users will be able to fix the warning by simply removing a semicolon. In the future, I'd like to enable this lint unconditionally, and eventually make it into a hard error in a future edition. This PR is a step towards that goal.
2021-07-30Add regression test for issue #87450.Hans Kratz-0/+43
2021-07-30Auto merge of #87421 - estebank:perf-run, r=oli-obkbors-1/+462
Do not discard `?Sized` type params and suggest their removal
2021-07-30Properly find owner of closure in THIR unsafeckLeSeulArtichaut-0/+15
Co-authored-by: FabianWolff <fabian.wolff@alumni.ethz.ch>
2021-07-31Implement trait upcasting coercion type-checking.Charles Lew-5/+54
2021-07-31Add feature gate tests.Charles Lew-6/+31
2021-07-30Use multispan suggestions more oftenEsteban Küber-333/+473
* Use more accurate span for `async move` suggestion * Use more accurate span for deref suggestion * Use `multipart_suggestion` more often
2021-07-30Tweak borrowing suggestion in `for` loopEsteban Küber-14/+37
2021-07-30Do not discard `?Sized` type params and suggest their removalEsteban Küber-1/+462
2021-07-30Fix error with suggestion for how to disambiguate associated function when ↵Ryan Levick-0/+108
struct is generic
2021-07-30Auto merge of #85971 - FabianWolff:issue-85586, r=davidtwcobors-0/+21
Use more precise span for E0282 in cast expressions This pull request fixes #85586. The example code given there: ```rust fn main() { let a = [1, 2, 3].iter().sum(); let b = (a + 1) as usize; } ``` currently produces ``` error[E0282]: type annotations needed --> issue-85586.rs:3:13 | 3 | let b = (a + 1) as usize; | ^^^^^^^^^^^^^^^^ cannot infer type | = note: type must be known at this point error: aborting due to previous error ``` even though the type of the entire cast expression quite clearly should be `usize`. The error is in the cast's left-hand side, which is made explicit by the changes in this PR: ``` error[E0282]: type annotations needed --> issue-85586.rs:3:13 | 3 | let b = (a + 1) as usize; | ^^^^^^^ cannot infer type | = note: type must be known at this point error: aborting due to previous error ```
2021-07-30Auto merge of #87237 - jonas-schievink:const-for-and-try, r=oli-obkbors-16/+145
Add feature gates for `for` and `?` in consts These operations seems *relatively* straightforward to support, and only seem to be blocked on `impl const Trait`. I have included a working test for `const_try`, but `const_for` is currently unusable without reimplementing *every single* defaulted `Iterator` method, so I didn't do that. (both features still need tracking issues before this is merged)
2021-07-30Auto merge of #87615 - JohnTitor:rollup-t5jpmrg, r=JohnTitorbors-0/+72
Rollup of 10 pull requests Successful merges: - #87052 (Optimize fmt::PadAdapter::wrap) - #87522 (Fix assert in diy_float) - #87553 (Fix typo in rustc_driver::version) - #87554 (2229: Discr should be read when PatKind is Range) - #87564 (min_type_alias_impl_trait is going to be removed in 1.56) - #87574 (Update the examples in `String` and `VecDeque::retain`) - #87583 (Refactor compression cache in v0 symbol mangler) - #87585 (Add missing links for core::char types) - #87594 (fs File get_path procfs usage for netbsd same as linux.) - #87602 ([backtraces]: look for the `begin` symbol only after seeing `end`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-07-30Rollup merge of #87602 - ↵Yuki Okushi-0/+58
wesleywiser:partially_fix_short_backtraces_windows_optimized, r=dtolnay [backtraces]: look for the `begin` symbol only after seeing `end` On `x86_64-pc-windows-msvc`, we often get backtraces which look like this: ``` 10: 0x7ff77e0e9be5 - std::panicking::rust_panic_with_hook 11: 0x7ff77e0e11b4 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c 12: 0x7ff77e0e116f - std::sys_common::backtrace::__rust_end_short_backtrace::h61c7ecb1b55338ae 13: 0x7ff77e0f89dd - std::panicking::begin_panic::h8e60ef9f82a41805 14: 0x7ff77e0e108c - d 15: 0x7ff77e0e1069 - c 16: 0x7ff77e0e1059 - b 17: 0x7ff77e0e1049 - a 18: 0x7ff77e0e1039 - core::ptr::drop_in_place<std::rt::lang_start<()>::{{closure}}>::h1bfcd14d5e15ba81 19: 0x7ff77e0e1186 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5769736bdb11136c 20: 0x7ff77e0e100c - std::rt::lang_start::{{closure}}::ha054184bbf9921e3 ``` Notice that `__rust_begin_short_backtrace` appears on frame 11 before `__rust_end_short_backtrace` on frame 12. This is because in typical release binaries without debug symbols, dbghelp.dll, which we use to walk and symbolize the stack, does not know where CGU internal functions start or end and so the closure invoked by `__rust_end_short_backtrace` is incorrectly described as `__rust_begin_short_backtrace` because it happens to be near that symbol. While that can obviously change, this has been happening quite consistently since #75048. Since this is a very small change to the std and the change makes sense by itself, I think this is worth doing. This doesn't completely resolve the situation for release binaries on Windows, since without debug symbols, the stack printed can still show incorrect symbol names (this is why the test uses `#[no_mangle]`) but it does slightly improve the situation in that you see the same backtrace you would see with `RUST_BACKTRACE=full` or in a debugger (without the uninteresting bits at the top and bottom). Fixes part of #87481
2021-07-30Rollup merge of #87554 - sexxi-goose:fix-issue-87426, r=nikomatsakisYuki Okushi-0/+14
2229: Discr should be read when PatKind is Range This PR fixes an issue related to pattern matching in closures when Edition 2021 is enabled. - If any of the patterns the discr is being matched on is `PatKind::Range` then the discr should be read r? ```@nikomatsakis``` Closes https://github.com/rust-lang/rust/issues/87426
2021-07-30Auto merge of #87483 - oli-obk:tait_ice, r=lqdbors-0/+73
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution Fixes #87455 This situation was unreachable before #87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After #87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).