about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2021-08-04Fix assertions in `coverage-reports` testAlex Crichton-76/+70
Update some `C-unwind` bits and then
2021-08-03Relax a codegen testAlex Crichton-1/+1
nounwind is no longer emitted but the test still passes
2021-08-03Make simplify_cfg test more consistentAlex Crichton-47/+50
Force it to always use panic=abort which means that all targets should produce the same MIR now.
2021-08-03rustc: Fill out remaining parts of C-unwind ABIAlex Crichton-209/+134
This commit intends to fill out some of the remaining pieces of the C-unwind ABI. This has a number of other changes with it though to move this design space forward a bit. Notably contained within here is: * On `panic=unwind`, the `extern "C"` ABI is now considered as "may unwind". This fixes a longstanding soundness issue where if you `panic!()` in an `extern "C"` function defined in Rust that's actually UB because the LLVM representation for the function has the `nounwind` attribute, but then you unwind. * Whether or not a function unwinds now mainly considers the ABI of the function instead of first checking the panic strategy. This fixes a miscompile of `extern "C-unwind"` with `panic=abort` because that ABI can still unwind. * The aborting stub for non-unwinding ABIs with `panic=unwind` has been reimplemented. Previously this was done as a small tweak during MIR generation, but this has been moved to a separate and dedicated MIR pass. This new pass will, for appropriate functions and function calls, insert a `cleanup` landing pad for any function call that may unwind within a function that is itself not allowed to unwind. Note that this subtly changes some behavior from before where previously on an unwind which was caught-to-abort it would run active destructors in the function, and now it simply immediately aborts the process. * The `#[unwind]` attribute has been removed and all users in tests and such are now using `C-unwind` and `#![feature(c_unwind)]`. I think this is largely the last piece of the RFC to implement. Unfortunately I believe this is still not stabilizable as-is because activating the feature gate changes the behavior of the existing `extern "C"` ABI in a way that has no replacement. My thinking for how to enable this is that we add support for the `C-unwind` ABI on stable Rust first, and then after it hits stable we change the behavior of the `C` ABI. That way anyone straddling stable/beta/nightly can switch to `C-unwind` safely.
2021-08-03Auto merge of #87725 - JohnTitor:rollup-2ywcpuk, r=JohnTitorbors-16/+202
Rollup of 8 pull requests Successful merges: - #87645 (Properly find owner of closure in THIR unsafeck) - #87646 (Fix a parser ICE on invalid `fn` body) - #87652 (Validate that naked functions are never inlined) - #87685 (Write docs for SyncOnceCell From and Default impl) - #87693 (Add `aarch64-apple-ios-sim` as a possible target to the manifest) - #87708 (Add convenience method for handling ipv4-mapped addresses by canonicalizing them) - #87711 (Correct typo) - #87716 (Allow generic SIMD array element type) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-03Rollup merge of #87716 - calebzulawski:master, r=workingjubileeYuki Okushi-15/+61
Allow generic SIMD array element type Fixes the following: ```rust #[repr(simd)] struct V<T>([T; 4]); ``` cc ``@workingjubilee``
2021-08-03Rollup merge of #87652 - npmccallum:naked_inline, r=AmanieuYuki Okushi-1/+98
Validate that naked functions are never inlined Reject all uses of the inline attribute on naked functions. https://github.com/rust-lang/rfcs/pull/2774 https://github.com/rust-lang/rfcs/pull/2972 cc `@joshtriplett` `@tmiasko` `@Amanieu`
2021-08-03Rollup merge of #87646 - JohnTitor:fix-parser-ice, r=oli-obkYuki Okushi-0/+28
Fix a parser ICE on invalid `fn` body Fixes #87635 A better fix would add a check for `fn` body on `expected_one_of_not_found` but I haven't come up with a graceful way. Any idea? r? ```@oli-obk``` ```@estebank```
2021-08-03Rollup merge of #87645 - LeSeulArtichaut:issue-87414, r=oli-obkYuki Okushi-0/+15
Properly find owner of closure in THIR unsafeck Previously, when encountering a closure in a constant, the THIR unsafeck gets invoked on the owner of the constant instead of the constant itself, producing cycles. Supersedes #87492. ```@FabianWolff``` thanks for your work on that PR, I copied your test file and added you as a co-author. Fixes #87414. r? ```@oli-obk```
2021-08-03Auto merge of #87033 - FabianWolff:issue-87017, r=estebankbors-0/+94
Provide a suggestion when trying to destructure a `Vec` as a slice Fixes #87017. r? `@estebank`
2021-08-03Auto merge of #87262 - dtolnay:negative, r=Aaron1011bors-0/+11
Support negative numbers in Literal::from_str proc_macro::Literal has allowed negative numbers in a single literal token ever since Rust 1.29, using https://doc.rust-lang.org/stable/proc_macro/struct.Literal.html#method.isize_unsuffixed and similar constructors. ```rust let lit = proc_macro::Literal::isize_unsuffixed(-10); ``` However, the suite of constructors on Literal is not sufficient for all use cases, for example arbitrary precision floats, or custom suffixes in FFI macros. ```rust let lit = proc_macro::Literal::f64_unsuffixed(0.101001000100001000001000000100000001); // :( let lit = proc_macro::Literal::i???_suffixed(10ulong); // :( ``` For those, macros construct the literal using from_str instead, which preserves arbitrary precision, custom suffixes, base, and digit grouping. ```rust let lit = "0.101001000100001000001000000100000001".parse::<Literal>().unwrap(); let lit = "10ulong".parse::<Literal>().unwrap(); let lit = "0b1000_0100_0010_0001".parse::<Literal>().unwrap(); ``` However, until this PR it was not possible to construct a literal token that is **both** negative **and** preserving of arbitrary precision etc. This PR fixes `Literal::from_str` to recognize negative integer and float literals.
2021-08-03Allow generic SIMD array element typeCaleb Zulawski-15/+61
2021-08-02Validate that naked functions are never inlinedNathaniel McCallum-1/+98
Reject all uses of the inline attribute on naked functions. rust-lang/rfcs#2774 rust-lang/rfcs#2972
2021-08-02Auto merge of #87628 - estebank:unmet-explicit-lifetime-bound, r=oli-obkbors-27/+140
Point at unmet explicit lifetime obligation bound r? `@oli-obk` Split off of #85799.
2021-08-02Run rustfix in `pattern-slice-vec.rs` UI testFabian Wolff-4/+46
2021-08-02Auto merge of #87698 - camsteffen:rollup-yvjfc26, r=camsteffenbors-69/+189
Rollup of 6 pull requests Successful merges: - #86176 (Implement a `explicit_generic_args_with_impl_trait` feature gate) - #87654 (Add documentation for the order of Option and Result) - #87659 (Fix invalid suggestions for non-ASCII characters in byte constants) - #87673 (Tweak opaque type mismatch error) - #87687 (Inline some macros) - #87690 (Add missing "allocated object" doc link to `<*mut T>::add`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-08-02Rollup merge of #87673 - estebank:opaque-ty-mismatch, r=davidtwcoCameron Steffen-57/+71
Tweak opaque type mismatch error
2021-08-02Rollup merge of #87659 - FabianWolff:issue-87397, r=davidtwcoCameron Steffen-12/+69
Fix invalid suggestions for non-ASCII characters in byte constants Fixes #87397.
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-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-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-31Auto merge of #87610 - Aaron1011:bump-llvm-bugfix, r=cuviperbors-6/+2
Bump LLVM for RegAllocFast bugfix Fixes #83854 cc `@cuviper`
2021-07-31Point at unmet explicit lifetime obligation boundEsteban Küber-27/+140
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