about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2020-10-26Do not ICE on invalid inputEsteban Küber-0/+76
2020-10-26Auto merge of #78324 - RalfJung:uninhabited-statics, r=oli-obkbors-0/+64
ensure that statics are inhabited Fixes https://github.com/rust-lang/rust/issues/74840 r? `@oli-obk`
2020-10-26Auto merge of #78387 - Dylan-DPC:rollup-ch0st6z, r=Dylan-DPCbors-134/+516
Rollup of 10 pull requests Successful merges: - #74477 (`#[deny(unsafe_op_in_unsafe_fn)]` in sys/wasm) - #77836 (transmute_copy: explain that alignment is handled correctly) - #78126 (Properly define va_arg and va_list for aarch64-apple-darwin) - #78137 (Initialize tracing subscriber in compiletest tool) - #78161 (Add issue template link to IRLO) - #78214 (Tweak match arm semicolon removal suggestion to account for futures) - #78247 (Fix #78192) - #78252 (Add codegen test for #45964) - #78268 (Do not try to report on closures to avoid ICE) - #78295 (Add some regression tests) Failed merges: r? `@ghost`
2020-10-26Rollup merge of #78295 - Alexendoo:ice-regression-tests, r=nagisaDylan DPC-0/+134
Add some regression tests Closes #56229 Closes #59494 Closes #70746 Closes #73229
2020-10-26Rollup merge of #78268 - JohnTitor:issue-78262, r=estebankDylan DPC-0/+42
Do not try to report on closures to avoid ICE Fixes #78262
2020-10-26Rollup merge of #78252 - bugadani:issue-45964, r=Mark-SimulacrumDylan DPC-0/+38
Add codegen test for #45964 Closes #45964
2020-10-26Rollup merge of #78247 - simonvandel:fix-78192, r=oli-obkDylan DPC-3/+41
Fix #78192 Check which places are marked dead. Fixes #78192
2020-10-26Rollup merge of #78214 - estebank:match-semicolon, r=oli-obkDylan DPC-131/+261
Tweak match arm semicolon removal suggestion to account for futures * Tweak and extend "use `.await`" suggestions * Suggest removal of semicolon on prior match arm * Account for `impl Future` when suggesting semicolon removal * Silence some errors when encountering `await foo()?` as can't be certain what the intent was *Thanks to https://twitter.com/a_hoverbear/status/1318960787105353728 for pointing this out!*
2020-10-26Auto merge of #77283 - estebank:if-let-sugg, r=Mark-Simulacrumbors-12/+28
Tweak `if let` suggestion to be more liberal with suggestion and to not ICE Fix #77218. Fix #77238.
2020-10-25Tweak `if let` suggestion to be more liberal with suggestion and to not ICEEsteban Küber-12/+28
Fix #77218. Fix #77238.
2020-10-25Auto merge of #77901 - jonas-schievink:unignore-test-36710, r=Mark-Simulacrumbors-2/+2
Unignore test for #36710 on MUSL This now works fine thanks to autodetected `-C link-self-contained`. Closes #36710
2020-10-25Auto merge of #78253 - Aaron1011:bump-llvm-deadarg, r=cuviperbors-0/+51
Bump LLVM for DeadArgElim fix Fixes #76387 Pulls in https://github.com/rust-lang/llvm-project/pull/82
2020-10-25also test non-extern uninhabited staticsRalf Jung-1/+26
2020-10-25Rollup merge of #78326 - Aaron1011:fix/min-stmt-lints, r=petrochenkovYuki Okushi-4/+49
Split out statement attributes changes from #78306 This is the same as PR https://github.com/rust-lang/rust/pull/78306, but `unused_doc_comments` is modified to explicitly ignore statement items (which preserves the current behavior). This shouldn't have any user-visible effects, so it can be landed without lang team discussion. --------- When the 'early' and 'late' visitors visit an attribute target, they activate any lint attributes (e.g. `#[allow]`) that apply to it. This can affect warnings emitted on sibiling attributes. For example, the following code does not produce an `unused_attributes` for `#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed the warning. ```rust trait Foo { #[allow(unused_attributes)] #[inline] fn first(); #[inline] #[allow(unused_attributes)] fn second(); } ``` However, we do not do this for statements - instead, the lint attributes only become active when we visit the struct nested inside `StmtKind` (e.g. `Item`). Currently, this is difficult to observe due to another issue - the `HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`. As a result, the `unused_doc_comments` lint will never see attributes on item statements. This commit makes two interrelated fixes to the handling of inert (non-proc-macro) attributes on statements: * The `HasAttr` impl for `StmtKind` now returns attributes for `StmtKind::Item`, treating it just like every other `StmtKind` variant. The only place relying on the old behavior was macro which has been updated to explicitly ignore attributes on item statements. This allows the `unused_doc_comments` lint to fire for item statements. * The `early` and `late` lint visitors now activate lint attributes when invoking the callback for `Stmt`. This ensures that a lint attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to sibiling attributes on an item statement. For now, the `unused_doc_comments` lint is explicitly disabled on item statements, which preserves the current behavior. The exact locatiosn where this lint should fire are being discussed in PR #78306
2020-10-25Rollup merge of #78208 - liketechnik:issue-69399, r=oli-obkYuki Okushi-11/+39
replace `#[allow_internal_unstable]` with `#[rustc_allow_const_fn_unstable]` for `const fn`s `#[allow_internal_unstable]` is currently used to side-step feature gate and stability checks. While it was originally only meant to be used only on macros, its use was expanded to `const fn`s. This pr adds stricter checks for the usage of `#[allow_internal_unstable]` (only on macros) and introduces the `#[rustc_allow_const_fn_unstable]` attribute for usage on `const fn`s. This pr does not change any of the functionality associated with the use of `#[allow_internal_unstable]` on macros or the usage of `#[rustc_allow_const_fn_unstable]` (instead of `#[allow_internal_unstable]`) on `const fn`s (see https://github.com/rust-lang/rust/issues/69399#issuecomment-712911540). Note: The check for `#[rustc_allow_const_fn_unstable]` currently only validates that the attribute is used on a function, because I don't know how I would check if the function is a `const fn` at the place of the check. I therefore openend this as a 'draft pull request'. Closes rust-lang/rust#69399 r? @oli-obk
2020-10-25Rollup merge of #77984 - Aaron1011:fix/macro-mod-weird-parent, r=petrochenkovYuki Okushi-0/+25
Compute proper module parent during resolution Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-25Auto merge of #77546 - lcnr:impl-trait-closure, r=eddybbors-0/+21
fix def collector for impl trait fixes #77329 We now consistently make `impl Trait` a hir owner, requiring some special casing for synthetic generic params. r? `@eddyb`
2020-10-25Test with NLL explicitlyYuki Okushi-4/+19
2020-10-25Auto merge of #77526 - RalfJung:dont-promote-unions, r=lcnrbors-1/+16
stop promoting union field accesses in 'const' Turns out that promotion of union field accesses is the only difference between "promotion in `const`/`static` bodies" and "explicit promotion". So if we can remove this, we have finally achieved what I thought to already be the case -- that the bodies of `const`/`static` initializers behave the same as explicit promotion contexts. The reason we do not want to promote union field accesses is that they can introduce UB, i.e., they can go wrong. We want to [minimize the ways promoteds can fail to evaluate](https://github.com/rust-lang/const-eval/issues/53). Also this change makes things more consistent overall, removing a special case that was added without much consideration (as far as I can tell). Cc `@rust-lang/wg-const-eval`
2020-10-25Do not try to report on closures to avoid ICEYuki Okushi-0/+27
2020-10-24Auto merge of #78334 - jonas-schievink:rollup-z0gzbmm, r=jonas-schievinkbors-61/+808
Rollup of 12 pull requests Successful merges: - #75115 (`#[deny(unsafe_op_in_unsafe_fn)]` in sys/cloudabi) - #76614 (change the order of type arguments on ControlFlow) - #77610 (revise Hermit's mutex interface to support the behaviour of StaticMutex) - #77830 (Simplify query proc-macros) - #77930 (Do not ICE with TraitPredicates containing [type error]) - #78069 (Fix const core::panic!(non_literal_str).) - #78072 (Cleanup constant matching in exhaustiveness checking) - #78119 (Throw core::panic!("message") as &str instead of String.) - #78191 (Introduce a temporary for discriminant value in MatchBranchSimplification) - #78272 (const_evaluatable_checked: deal with unused nodes + div) - #78318 (TyCtxt: generate single impl block with `slice_interners` macro) - #78327 (resolve: Relax macro resolution consistency check to account for any errors) Failed merges: r? `@ghost`
2020-10-24Rollup merge of #78327 - petrochenkov:inconsist, r=Aaron1011Jonas Schievink-0/+25
resolve: Relax macro resolution consistency check to account for any errors The check was previously omitted only when ambiguity errors or `Res::Err` were encountered, but the "macro-expanded `extern crate` items cannot shadow..." error (at least) can cause same inconsistencies as well. Fixes https://github.com/rust-lang/rust/issues/78325
2020-10-24Rollup merge of #78272 - lcnr:abstract-const-unused-node, r=oli-obkJonas Schievink-0/+68
const_evaluatable_checked: deal with unused nodes + div r? @oli-obk
2020-10-24Rollup merge of #78191 - tmiasko:temp-match-branch-simplification, r=oli-obkJonas Schievink-40/+287
Introduce a temporary for discriminant value in MatchBranchSimplification The optimization introduces additional uses of the discriminant operand, but does not ensure that it is still valid to evaluate it or that it still evaluates to the same value. Evaluate it once at original position, and store the result in a new temporary. Follow up on #78151. The optimization remains disabled by default. Closes #78239.
2020-10-24Rollup merge of #78119 - fusion-engineering-forks:panic-use-as-str, r=AmanieuJonas Schievink-2/+2
Throw core::panic!("message") as &str instead of String. This makes `core::panic!("message")` consistent with `std::panic!("message")`, which throws a `&str` and not a `String`. This also makes any other panics from `core::panicking::panic` result in a `&str` rather than a `String`, which includes compiler-generated panics such as the panics generated for `mem::zeroed()`. --- Demonstration: ```rust use std::panic; use std::any::Any; fn main() { panic::set_hook(Box::new(|panic_info| check(panic_info.payload()))); check(&*panic::catch_unwind(|| core::panic!("core")).unwrap_err()); check(&*panic::catch_unwind(|| std::panic!("std")).unwrap_err()); } fn check(msg: &(dyn Any + Send)) { if let Some(s) = msg.downcast_ref::<String>() { println!("Got a String: {:?}", s); } else if let Some(s) = msg.downcast_ref::<&str>() { println!("Got a &str: {:?}", s); } } ``` Before: ``` Got a String: "core" Got a String: "core" Got a &str: "std" Got a &str: "std" ``` After: ``` Got a &str: "core" Got a &str: "core" Got a &str: "std" Got a &str: "std" ```
2020-10-24Rollup merge of #78072 - Nadrieril:cleanup-constant-matching, r=varkorJonas Schievink-2/+322
Cleanup constant matching in exhaustiveness checking This supercedes https://github.com/rust-lang/rust/pull/77390. I made the `Opaque` constructor work. I have opened two issues https://github.com/rust-lang/rust/issues/78071 and https://github.com/rust-lang/rust/issues/78057 from the discussion we had on the previous PR. They are not regressions nor directly related to the current PR so I thought we'd deal with them separately. I left a FIXME somewhere because I didn't know how to compare string constants for equality. There might even be some unicode things that need to happen there. In the meantime I preserved previous behavior. EDIT: I accidentally fixed #78071
2020-10-24Rollup merge of #78069 - fusion-engineering-forks:core-const-panic-str, ↵Jonas Schievink-17/+45
r=RalfJung Fix const core::panic!(non_literal_str). Invocations of `core::panic!(x)` where `x` is not a string literal expand to `panic!("{}", x)`, which is not understood by the const panic logic right now. This adds `panic_str` as a lang item, and modifies the const eval implementation to hook into this item as well. This fixes the issue mentioned here: https://github.com/rust-lang/rust/issues/51999#issuecomment-687604248 r? `@RalfJung` `@rustbot` modify labels: +A-const-eval
2020-10-24Rollup merge of #77930 - estebank:ice-77919, r=eddybJonas Schievink-0/+59
Do not ICE with TraitPredicates containing [type error] Fix #77919.
2020-10-24Auto merge of #77255 - Aaron1011:feature/collect-attr-tokens, r=petrochenkovbors-10/+10
Unconditionally capture tokens for attributes. This allows us to avoid synthesizing tokens in `prepend_attr`, since we have the original tokens available. We still need to synthesize tokens when expanding `cfg_attr`, but this is an unavoidable consequence of the syntax of `cfg_attr` - the user does not supply the `#` and `[]` tokens that a `cfg_attr` expands to. This is based on PR https://github.com/rust-lang/rust/pull/77250 - this PR exposes a bug in the current `collect_tokens` implementation, which is fixed by the rewrite.
2020-10-24Compute proper module parent during resolutionAaron Hill-0/+25
Fixes #75982 The direct parent of a module may not be a module (e.g. `const _: () = { #[path = "foo.rs"] mod foo; };`). To find the parent of a module for purposes of resolution, we need to walk up the tree until we hit a module or a crate root.
2020-10-24resolve: Relax macro resolution consistency check to account for any errorsVadim Petrochenkov-0/+25
2020-10-24Fix inconsistencies in handling of inert attributes on statementsAaron Hill-4/+49
When the 'early' and 'late' visitors visit an attribute target, they activate any lint attributes (e.g. `#[allow]`) that apply to it. This can affect warnings emitted on sibiling attributes. For example, the following code does not produce an `unused_attributes` for `#[inline]`, since the sibiling `#[allow(unused_attributes)]` suppressed the warning. ```rust trait Foo { #[allow(unused_attributes)] #[inline] fn first(); #[inline] #[allow(unused_attributes)] fn second(); } ``` However, we do not do this for statements - instead, the lint attributes only become active when we visit the struct nested inside `StmtKind` (e.g. `Item`). Currently, this is difficult to observe due to another issue - the `HasAttrs` impl for `StmtKind` ignores attributes for `StmtKind::Item`. As a result, the `unused_doc_comments` lint will never see attributes on item statements. This commit makes two interrelated fixes to the handling of inert (non-proc-macro) attributes on statements: * The `HasAttr` impl for `StmtKind` now returns attributes for `StmtKind::Item`, treating it just like every other `StmtKind` variant. The only place relying on the old behavior was macro which has been updated to explicitly ignore attributes on item statements. This allows the `unused_doc_comments` lint to fire for item statements. * The `early` and `late` lint visitors now activate lint attributes when invoking the callback for `Stmt`. This ensures that a lint attribute (e.g. `#[allow(unused_doc_comments)]`) can be applied to sibiling attributes on an item statement. For now, the `unused_doc_comments` lint is explicitly disabled on item statements, which preserves the current behavior. The exact locatiosn where this lint should fire are being discussed in PR #78306
2020-10-24ensure that statics are inhabitedRalf Jung-0/+39
2020-10-24Add some regression testsAlex Macleod-0/+134
Closes #56229 Closes #59494 Closes #70746 Closes #73229
2020-10-24Rollup merge of #78264 - JohnTitor:macro-test, r=petrochenkovJonas Schievink-0/+10
Add regression test for issue-77475 Closes #77475
2020-10-24Rollup merge of #78249 - lcnr:ct-infer-origin, r=varkorJonas Schievink-1/+1
improve const infer error For type inference we probably have to be careful about subtyping and stuff but considering that subtyping shouldn't be relevant for constants I don't really see a reason why we may not want to reuse the const origin here. r? `@varkor`
2020-10-23Do not ICE with TraitPredicates containing [type error]Esteban Küber-0/+59
Fix #77919.
2020-10-23Auto merge of #77015 - davidtwco:check-attr-variant-closure-expr, r=lcnrbors-73/+81
passes: `check_attr` on more targets This PR modifies `check_attr` so that: - Enum variants are now checked (some attributes would not have been prohibited on variants previously). - `check_expr_attributes` and `check_stmt_attributes` are removed as `check_attributes` can perform the same checks. This means that codegen attribute errors aren't shown if there are other errors first (e.g. from other attributes, as shown in `src/test/ui/macros/issue-68060.rs` changes below).
2020-10-23Suggest semicolon removal and boxing when appropriateEsteban Küber-8/+15
2020-10-23Add more `.await` suggestions on E0308Esteban Küber-46/+35
2020-10-23Add test case for different `impl Future`sEsteban Küber-3/+36
2020-10-23Silence unnecessary `await foo?` knock-down errorEsteban Küber-67/+33
2020-10-23Account for possible boxable `impl Future` in semicolon removal suggestionsEsteban Küber-4/+48
2020-10-23Suggest semicolon removal on prior match armEsteban Küber-0/+85
2020-10-23Tweak "use `.await`" suggestionEsteban Küber-38/+44
2020-10-23reviewBastian Kauschke-3/+9
2020-10-23const_eval_checked: deal with unused nodes + divBastian Kauschke-0/+62
2020-10-23Rollup merge of #78265 - JohnTitor:type-iference-diag-test, r=lcnrYuki Okushi-0/+78
Add some inference-related regression tests about incorrect diagnostics Closes #71732 Closes #72616
2020-10-23Rollup merge of #78263 - JohnTitor:mir-opt-ice-test, r=lcnrYuki Okushi-0/+4
Add regression test of issue-77668 Closes #77668
2020-10-23Rollup merge of #78255 - dtolnay:match, r=lcnrYuki Okushi-13/+37
Reduce diagram mess in 'match arms have incompatible types' error I noticed this wild diagram in https://twitter.com/a_hoverbear/status/1318960787105353728 which I think does not benefit from the big outer vertical span. This PR shrinks the outer span to cover just the `match` keyword and scrutinee expression *if* at least one of the highlighted match arms involved in the error is multiline. **Before:** <pre> <b>error[E0308]: `match` arms have incompatible types</b> <b>--&gt;</b> src/topology/builder.rs:141:35 <b>|</b> <b>120 |</b> let transform = match transform { <b>| _________________________-</b> <b>121 | |</b> Transform::Function(t) =&gt; { <b>| _|_______________________________________-</b> <b>122 | | |</b> filter_event_type(input_rx, input_type).compat().flat_map(|v| { <b>123 | | |</b> futures::stream::iter(match v { <b>124 | | |</b> Err(e) =&gt; { <b>... | |</b> <b>139 | | |</b> .compat(); <b>140 | | |</b> } <b>| |_|_____________- this is found to be of type `()`</b> <b>141 | |</b> Transform::Task(t) =&gt; t <b>| _|___________________________________^</b> <b>142 | | |</b> .transform(filter_event_type(input_rx, input_type)) <b>143 | | |</b> .forward(output) <b>144 | | |</b> .map(|_| debug!("Finished")) <b>145 | | |</b> .compat(), <b>| |_|_________________________^ expected `()`, found struct `futures::compat::Compat01As03`</b> <b>146 | |</b> }; <b>| |_________- `match` arms have incompatible types</b> <b>|</b> <b>= note:</b> expected type `<b>()</b>` found struct `<b>futures::compat::Compat01As03&lt;futures::Map&lt;futures::stream::Forward&lt;std::boxed::Box&lt;dyn futures::Stream&lt;Error = (), Item = event::Event&gt; + std::marker::Send&gt;, topology::fanout::Fanout&gt;, [closure@src/topology/builder.rs:144:22: 144:44]&gt;&gt;</b>` </pre> **After:** <pre> <b>error[E0308]: `match` arms have incompatible types</b> <b>--&gt;</b> src/topology/builder.rs:141:35 <b>|</b> <b>120 |</b> let transform = match transform { <b>| --------------- `match` arms have incompatible types</b> <b>121 |</b> Transform::Function(t) =&gt; { <b>| _________________________________________-</b> <b>122 | |</b> filter_event_type(input_rx, input_type).compat().flat_map(|v| { <b>123 | |</b> futures::stream::iter(match v { <b>124 | |</b> Err(e) =&gt; { <b>... |</b> <b>139 | |</b> .compat(); <b>140 | |</b> } <b>| |_______________- this is found to be of type `()`</b> <b>141 |</b> Transform::Task(t) =&gt; t <b>| _____________________________________^</b> <b>142 | |</b> .transform(filter_event_type(input_rx, input_type)) <b>143 | |</b> .forward(output) <b>144 | |</b> .map(|_| debug!("Finished")) <b>145 | |</b> .compat(), <b>| |___________________________^ expected `()`, found struct `futures::compat::Compat01As03`</b> <b>|</b> <b>= note:</b> expected type `<b>()</b>` found struct `<b>futures::compat::Compat01As03&lt;futures::Map&lt;futures::stream::Forward&lt;std::boxed::Box&lt;dyn futures::Stream&lt;Error = (), Item = event::Event&gt; + std::marker::Send&gt;, topology::fanout::Fanout&gt;, [closure@src/topology/builder.rs:144:22: 144:44]&gt;&gt;</b>` </pre> FYI @Hoverbear