about summary refs log tree commit diff
path: root/src/test/ui
AgeCommit message (Collapse)AuthorLines
2020-08-12Rollup merge of #74960 - nbdd0121:typeck, r=nikomatsakisYuki Okushi-0/+38
Fix regionck failure when converting Index to IndexMut Fixes #74933 Consider an overloaded index expression `base[index]`. Without knowing whether it will be mutated, this will initially be desugared into `<U as Index<T>>::index(&base, index)` for some `U` and `T`. Let `V` be the `expr_ty_adjusted` of `index`. If this expression ends up being used in any mutable context (or used in a function call with `&mut self` receiver before #72280), we will need to fix it up. The current code will rewrite it to `<U as IndexMut<V>>::index_mut(&mut base, index)`. In most cases this is fine as `V` will be equal to `T`, however this is not always true when `V/T` are references, as they may have different region. This issue is quite subtle before #72280 as this code path is only used to fixup function receivers, but after #72280 we've made this a common path. The solution is basically just rewrite it to `<U as IndexMut<T>>::index_mut(&mut base, index)`. `T` can retrieved in the fixup path using `node_substs`.
2020-08-11Auto merge of #74802 - Mark-Simulacrum:reland-74069, r=nnethercotebors-3/+28
Reland #74069 Investigation in #74716 has concluded that this PR is indeed not a regression (and in fact the rollup itself is not either). This reverts the revert in #74611. r? @nnethercote cc @eddyb
2020-08-11Rollup merge of #75359 - lcnr:unused-delims-trim, r=oli-obkYuki Okushi-7/+7
unused_delims: trim expr improves rustfix output.
2020-08-11Rollup merge of #75352 - estebank:incorrect-tuple-struct-pat, r=oli-obkYuki Okushi-8/+5
Tweak conditions for E0026 and E0769 When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax. Given ```rust fn main() { match MyOption::MySome(42) { MyOption::MySome { x: 42 } => (), _ => (), } } ``` We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant" instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-11Rollup merge of #75333 - davidtwco:polymorphization-75260-fixes, r=lcnrYuki Okushi-0/+14
polymorphize: constrain unevaluated const handling This PR constrains the support added for handling unevaluated consts in polymorphization (introduced in #75260) by: - Skipping associated constants as this causes cycle errors. - Skipping promoted constants when they contain `Self` as this ensures `T` is used in constants of the form `<Self as Foo<T>>`. Due to an oversight on my part, when landing #75260 and #75255, some tests started failing when polymorphization was enabled that I didn't notice until after landing - this PR fixes the regressions from #75260. r? @lcnr
2020-08-11Auto merge of #75383 - Dylan-DPC:rollup-6hi36zn, r=Dylan-DPCbors-0/+164
Rollup of 10 pull requests Successful merges: - #75098 (Clippy pointer cast lint experiment) - #75249 (Only add a border for the rust logo) - #75315 (Avoid deleting temporary files on error) - #75316 (Don't try to use wasm intrinsics on vectors) - #75337 (instance: only polymorphize upvar substs) - #75339 (evaluate required_consts when pushing stack frame in Miri engine) - #75363 (Use existing `infcx` when emitting trait impl diagnostic) - #75366 (Add help button) - #75369 (Move to intra-doc links in /library/core/src/borrow.rs) - #75379 (Use intra-doc links in /library/core/src/cmp.rs) Failed merges: r? @ghost
2020-08-11Rollup merge of #75363 - Aaron1011:fix/diag-infcx, r=lcnrDylan DPC-0/+101
Use existing `infcx` when emitting trait impl diagnostic Fixes #75361 Fixes #74918 Previously, we were creating a new `InferCtxt`, which caused an ICE when used with type variables from the existing `InferCtxt`
2020-08-11Rollup merge of #75339 - RalfJung:eval-required, r=oli-obkDylan DPC-0/+63
evaluate required_consts when pushing stack frame in Miri engine [Just like codegen](https://github.com/rust-lang/rust/pull/70820/files#diff-32c57af5c8e23eb048f55d1e955e5cd5R194), Miri needs to make sure all `required_consts` evaluate successfully, to catch post-monomorphization errors. While at it I also moved the const_eval error reporting logic into rustc_mir::const_eval::error; there is no reason it should be in `rustc_middle`. I kept this in a separate commit for easier reviewing. Helps with https://github.com/rust-lang/miri/issues/1382. I will add a test on the Miri side (done now: https://github.com/rust-lang/miri/pull/1504). r? @oli-obk
2020-08-10Auto merge of #74005 - estebank:type-ascription-redux, r=petrochenkovbors-122/+160
Clean up errors in typeck and resolve * Tweak ordering of suggestions * Do not suggest similarly named enclosing item * Point at item definition in foreign crates * Add missing primary label CC #34255.
2020-08-10Auto merge of #75349 - nnethercote:tweak-confusable-idents-checking, ↵bors-2/+13
r=petrochenkov Tweak confusable idents checking The confusable idents checking does some sub-optimal things with symbols. r? @petrochenkov cc @crlf0710
2020-08-10Add missing primary labelEsteban Küber-6/+6
2020-08-10Point at item definition in foreign cratesEsteban Küber-8/+40
2020-08-10Do not suggest similarly named enclosing itemEsteban Küber-41/+7
2020-08-10Tweak ordering of suggestionsEsteban Küber-81/+121
Modify logic to make it easier to follow and recover labels that would otherwise be lost.
2020-08-10Auto merge of #74953 - JulianKnodt:master, r=lcnrbors-55/+127
Remove restriction on type parameters preceding consts w/ feature const-generics Removed the restriction on type parameters preceding const parameters when the feature const-generics is enabled. Builds on #74676, which deals with unsorted generic parameters. This just lifts the check in lowering the AST to HIR that permits consts and types to be reordered with respect to each other. Lifetimes still must precede both This change is not intended for min-const-generics, and is gated behind the `#![feature(const_generics)]`. One thing is that it also permits type parameters without a default to come after consts, which I expected to not work, and was hoping to get more guidance on whether that should be permitted or how to prevent it otherwise. I did not go through the RFC process for this pull request because there was prior work to get this feature added. In the previous PR that was cited, work was done to enable this change. r? @lcnr
2020-08-10polymorphize: constrain unevaluated const handlingDavid Wood-0/+14
This commit constrains the support added for handling unevaluated consts in polymorphization (introduced in #75260) by: - Skipping associated constants as this causes cycle errors. - Skipping promoted constants when they contain `Self` as this ensures `T` is used in constants of the form `<Self as Foo<T>>`. Signed-off-by: David Wood <david@davidtw.co>
2020-08-10Use existing `infcx` when emitting trait impl diagnosticAaron Hill-0/+101
Fixes #75361 Fixes #74918 Previously, we were creating a new `InferCtxt`, which caused an ICE when used with type variables from the existing `InferCtxt`
2020-08-10unused_delims: trim exprBastian Kauschke-7/+7
2020-08-10add test for unused erroneous const in CTFERalf Jung-0/+63
2020-08-10Convert `Eq` impl to check Ord::Equalkadmin-1/+1
2020-08-09Tweak conditions for E0026 and E0769Esteban Küber-8/+5
When we have a tuple struct used with struct we don't want to suggest using the (valid) struct syntax with numeric field names. Instead we want to suggest the expected syntax. Given ```rust fn main() { match MyOption::MySome(42) { MyOption::MySome { x: 42 } => (), _ => (), } } ``` We now emit E0769 "tuple variant `MyOption::MySome` written as struct variant" instead of E0026 "variant `MyOption::MySome` does not have a field named `x`".
2020-08-10Auto merge of #75351 - JohnTitor:rollup-q9udsyx, r=JohnTitorbors-1/+35
Rollup of 8 pull requests Successful merges: - #74200 (Std panicking unsafe block in unsafe fn) - #75286 (Add additional case for Path starts with) - #75318 (Resolve `char` as a primitive even if there is a module in scope) - #75320 (Detect likely `for foo of bar` JS syntax) - #75328 (Cleanup E0749) - #75344 (Rename "Important traits" to "Notable traits") - #75348 (Move to intra-doc links in library/core/src/time.rs) - #75350 (Do not ICE when lowering invalid extern fn with bodies) Failed merges: r? @ghost
2020-08-10Rollup merge of #75350 - estebank:foreign-fn-with-body-ice, r=davidtwcoYuki Okushi-0/+24
Do not ICE when lowering invalid extern fn with bodies Fix #75283.
2020-08-10Rollup merge of #75320 - estebank:js-for-i-of-x, r=davidtwcoYuki Okushi-1/+11
Detect likely `for foo of bar` JS syntax Fix #75311.
2020-08-09Do not ICE when lowering invalid extern fn with bodiesEsteban Küber-0/+24
Fix #75283.
2020-08-10Fix symbol ordering for confusable idents detection.Nicholas Nethercote-2/+13
Confusable idents detection uses a type `BTreeMap<Symbol, Span>`. This is highly dubious given that `Symbol` doesn't guarantee a meaningful order. (In practice, it currently gives an order that mostly matches source code order.) As a result, changes in `Symbol` representation make the `lint-confusable-idents.rs` test fail, because this error message: > identifier pair considered confusable between `s` and `s` is changed to this: > identifier pair considered confusable between `s` and `s` and the corresponding span pointers get swapped erroneously, leading to an incorrect "previous identifier" label. This commit sorts the relevant symbols by span before doing the checking, which ensures that the ident that appears first in the code will be mentioned first in the message. The commit also extends the test slightly to be more thorough.
2020-08-09Remove normalization of `Span` debug output in proc-macro testsAaron Hill-163/+233
Fixes #74800 The definition of `is_x86_feature_detected!` (and similar macros) depends on the platform - it is produced by a `cfg_if!` invocation on x86, and a plain `#[cfg]` on other platforms. Since it is part of the prelude, we will end up importing different hygiene information depending on the platform. This previously required us to avoid printing raw `SyntaxContext` ids in any tests that uses the standard library, since the captured output will be platform-dependent. Previously, we replaced all `SyntaxContext` ids with "#CTXT", and the raw `Span` lo/hi bytes with "LO..HI". This commit adds `#![no_std]` and `extern crate std` to all proc-macro tests that print spans. This suppresses the prelude import, while still using lang items from `std` (which gives us a buildable binary). With this apporach, we will only load hygiene information for things which we explicitly import. This lets us re-add `-Z unpretty=expanded,hygiene`, since its output can now be made stable across all platforms. Additionally, we use `-Z span-debug` in more places, which lets us avoid the "LO..HI" normalization hack.
2020-08-09tests: Mark `ui/asm/bad-arch.rs` as requiring wasm llvm backendVadim Petrochenkov-1/+2
2020-08-09Change Ord impl for ParamKindOrdkadmin-46/+47
Updated tests and error msgs Update stderr from test Update w/ lcnr comments Change some tests around, and also updated Ord implementation for ParamKindOrd Update w/ nits from lcnr
2020-08-09Blessed old test where error message had changedkadmin-1/+1
Added minor fmt change to ast_validation
2020-08-09Test lifetimes after types after consts forbiddenkadmin-4/+41
Added more complex test and changed error message
2020-08-09Added +1 test for only works w/ feat const genkadmin-1/+54
Added this test to ensure that reordering the parameters only works with the feature const generics enabled. Fixed nits Also added another test to verify that intermixed lifetimes are forbidden
2020-08-08Detect likely `for foo of bar` JS syntaxEsteban Küber-1/+11
Fix #75311.
2020-08-08Auto merge of #75260 - davidtwco:polymorphization-promoted-substs, r=lcnrbors-2/+72
polymorphize: unevaluated constants This PR makes polymorphization visit the promoted MIR of unevaluated constants with available promoted MIR instead of visiting the substitutions of that constant - which will mark all of the generic parameters as used; in addition polymorphization will now visit non-promoted unevaluated constants rather than visit their substs. r? @lcnr
2020-08-08Rm restriction on ord of default types w/ constskadmin-37/+18
2020-08-08Auto merge of #74877 - lcnr:min_const_generics, r=oli-obkbors-66/+321
Implement the `min_const_generics` feature gate Implements both https://github.com/rust-lang/lang-team/issues/37 and https://github.com/rust-lang/compiler-team/issues/332. Adds the new feature gate `#![feature(min_const_generics)]`. This feature gate adds the following limitations to using const generics: - generic parameters must only be used in types if they are trivial. (either `N` or `{ N }`) - generic parameters must be either integers, `bool` or `char`. We do allow arbitrary expressions in associated consts though, meaning that the following is allowed, even if `<[u8; 0] as Foo>::ASSOC` is not const evaluatable. ```rust trait Foo { const ASSOC: usize; } impl<const N: usize> Foo for [u8; N] { const ASSOC: usize = 64 / N; } ``` r? @varkor cc @eddyb @withoutboats
2020-08-08Auto merge of #75048 - eggyal:force-no-tco-start-backtrace-frame, ↵bors-0/+23
r=Mark-Simulacrum Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised away I've stumbled across some situations where there (unexpectedly) was no `__rust_begin_short_backtrace` frame on the stack during unwinding. On closer examination, it appeared that the calls to that function had been tail-call optimised away. This PR follows [@bjorn3's suggestion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Disabling.20tail.20call.20optimisation.3F/near/205699133), by adding calls to `black_box` that hint to rustc not to perform TCO. Fixes #47429
2020-08-07Prevent `__rust_begin_short_backtrace` frames from being tail-call optimised ↵Alan Egerton-0/+23
away
2020-08-07Auto merge of #75255 - ↵bors-0/+135
davidtwco:polymorphisation-symbol-mangling-v0-upvar-closures, r=lcnr instance: polymorphize upvar closures/generators This PR modifies how instances are polymorphized so that closures and generators have any closures or generators captured within their upvars also polymorphized. With the new symbol mangling, a fully polymorphised closure will produce the same symbol regardless of what it was instantiated with. However, when that polymorphised closure captures another closure as an upvar, then the type of that other closure in the upvar substitution wouldn't have been polymorphised. The other closure will still refer to the initial substitutions. Therefore, the polymorphised closure will end up hashing differently but producing the same symbol - triggering `assert_symbols_are_distinct` in MIR partitioning. The old mangling scheme had a hash at the end that meant this didn't happen (this would still have been an issue, we just didn't have a way to notice). See [this Zulip discussion for further elaboration](https://rust-lang.zulipchat.com/#narrow/stream/216091-t-compiler.2Fwg-polymorphization/topic/symbol.20mangling.20v0.20.E2.9C.95.20polymorphisation/near/206152008). r? @eddyb cc @lcnr
2020-08-07instance: polymorphize upvar closures/generatorsDavid Wood-0/+135
This commit modifies how instances are polymorphized so that closures and generators have any closures or generators captured within their upvars also polymorphized - this avoids symbol clashes with the new symbol mangling scheme. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07polymorphize: non-promoted unevaluated constantsDavid Wood-0/+33
This commit makes polymorphization visit non-promoted unevaluated constants rather than visit their substs directly. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07Auto merge of #74821 - oli-obk:const_eval_read_uninit_fast_path, r=wesleywiserbors-3/+3
Check whether locals are too large instead of whether accesses into them are too large Essentially this stops const prop from attempting to optimize ```rust let mut x = [0_u8; 5000]; x[42] = 3; ``` I don't expect this to be a perf improvement without #73656 (which is also where the lack of this PR will be a perf regression). r? @wesleywiser
2020-08-07polymorphize: visit promoted MIRDavid Wood-2/+39
This commit makes polymorphization visited the MIR of unevaluated constants with available promoted MIR instead of visiting the substitutions of that constant - which will mark all of the generic parameters as used. Signed-off-by: David Wood <david@davidtw.co>
2020-08-07Auto merge of #74627 - petrochenkov:docbeauty2, r=Aaron1011bors-0/+78
rustc_ast: Stop using "string typing" for doc comment tokens Explicitly store their kind and style retrieved during lexing in the `token::DocComment`. Also don't "beautify" doc comments before converting them to `#[doc]` attributes when passing them to macros (both declarative and procedural). The trimming of empty lines, lines containing only `*`s, etc is purely a rustdoc's job as a part of its presentation of doc strings to users, rustc must not do this and must pass tokens as precisely as possible internally.
2020-08-06Rollup merge of #75227 - Amanieu:fix_asm_arch, r=Mark-SimulacrumManish Goregaokar-2/+28
Fix ICE when using asm! on an unsupported architecture Fixes #75220
2020-08-06Rollup merge of #75203 - canova:btreemap-into-iter, r=dtolnayManish Goregaokar-0/+23
Make `IntoIterator` lifetime bounds of `&BTreeMap` match with `&HashMap` This is a pretty small change on the lifetime bounds of `IntoIterator` implementations of both `&BTreeMap` and `&mut BTreeMap`. This is loosening the lifetime bounds, so more code should be accepted with this PR. This is lifetime bounds will still be implicit since we have `type Item = (&'a K, &'a V);` in the implementation. This change will make the HashMap and BTreeMap share the same signature, so we can share the same function/trait with both HashMap and BTreeMap in the code. Fixes #74034. r? @dtolnay hey, I was touching this file on my previous PR and wanted to fix this on the way. Would you mind taking a look at this, or redirecting it if you are busy?
2020-08-07test min_const_generics using revisionsBastian Kauschke-52/+154
2020-08-07Rollup merge of #75188 - Aaron1011:fix/fieldless-tuple-error, r=varkorYuki Okushi-0/+25
Handle fieldless tuple structs in diagnostic code Fixes #75062
2020-08-07Rollup merge of #74888 - infinity0:ignore-endian-big, r=nikomatsakisYuki Okushi-4/+2
compiletest: ignore-endian-big, fixes #74829, fixes #74885 See discussion on #74829 I tested it on a Debian s390x machine, works well.
2020-08-06allow complex expressions in assoc constsBastian Kauschke-17/+19