about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
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-83/+195
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-31/+94
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-11Rollup merge of #75337 - davidtwco:polymorphization-75255-fixes, r=eddybDylan DPC-52/+0
instance: only polymorphize upvar substs This PR restricts the substitution polymorphization added in #75255 to only apply to the tupled upvar substitution, rather than all substitutions, fixing a bunch of regressions when polymorphization is enabled. 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 #75255. #75336 has been filed to make sure that we don't forget to try make this change again in future, as it does enable some optimisations. r? @lcnr
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-10Auto merge of #75127 - jyn514:impl-trait, r=pnkfelixbors-95/+92
Fix async-std by special-casing rustdoc in typeck https://github.com/rust-lang/rust/issues/75100
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 #74936 - GuillaumeGomez:const-rustc_const_unstable, r=jyn514bors-0/+9
Don't print "const" keyword on non-nightly build if rustc_const_unstable is used on the item Fixes #74579.
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-10Add test for rustc_const_unstable on methodsGuillaume Gomez-0/+9
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-2/+41
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-10Rollup merge of #75318 - jyn514:primitive, r=manishearthYuki Okushi-1/+6
Resolve `char` as a primitive even if there is a module in scope Closes https://github.com/rust-lang/rust/issues/58699. r? @Manishearth
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-09bless MIRRalf Jung-31/+31
2020-08-09instance: only polymorphize upvar substsDavid Wood-52/+0
This commit restricts the substitution polymorphization added in #75255 to only apply to the tupled upvar substitution, rather than all substitutions, fixing a bunch of regressions when polymorphization is enabled. Signed-off-by: David Wood <david@davidtw.co>
2020-08-09Give precedence to primitives over modulesJoshua Nelson-1/+6
This has less surprising behavior when there is a module with the same name as a primitive in scope.
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-08Add another testJoshua Nelson-0/+32
2020-08-08Auto merge of #74533 - nikic:issue-74425, r=eddybbors-0/+25
Emit == null instead of <= null for niche check When the niche maximum is zero, emit a "== zero" check instead of a "<= zero" check. In particular, this avoids the awkward case of "<= null". While LLVM does canonicalize this to "== null", this apparently doesn't happen for constant expressions, leading to the issue in #74425. While that can be addressed on the LLVM side, it still seems prudent to emit sensible IR here, because this will allow null checks to be optimized earlier in the pipeline. Fixes #74425.
2020-08-08Emit == null instead of <= nullNikita Popov-0/+25
When the niche maximum is zero, emit a "== zero" check instead of a "<= zero" check. In particular, this avoid the awkward case of "<= null". While LLVM does canonicalize this to "!= null", this appently doesn't happen for constant expressions, leading to the issue in #74425. While that can be addressed on the LLVM side, it still seems prudent to emit sensible IR here, because this will allow null checks to be optimized earlier in the pipeline. Fixes #74425.
2020-08-08Auto merge of #74932 - nnethercote:rm-ast-session-globals, r=petrochenkovbors-4/+4
Remove `librustc_ast` session globals By moving the data onto `Session`. r? @petrochenkov
2020-08-08Rm restriction on ord of default types w/ constskadmin-37/+18
2020-08-08Auto merge of #75276 - JohnTitor:rollup-rz4hs0w, r=JohnTitorbors-4/+60
Rollup of 7 pull requests Successful merges: - #75224 (Don't call a function in function-arguments-naked.rs) - #75237 (Display elided lifetime for non-reference type in doc) - #75250 (make MaybeUninit::as_(mut_)ptr const) - #75253 (clean up const-hacks in int endianess conversion functions) - #75259 (Add missing backtick) - #75267 (Small cleanup) - #75270 (fix a couple of clippy findings) Failed merges: r? @ghost
2020-08-08Rollup merge of #75237 - nbdd0121:rustdoc, r=jyn514Yuki Okushi-0/+54
Display elided lifetime for non-reference type in doc In edition 2018 we encourage writing `<'_>` explicitly, so rustdoc should display like such as well. Fixes #75225 ~~Somehow when I run the compiled rustdoc using `cargo +stage2 doc` on other crates, it correctly produces `<'_>`, but I couldn't get the std doc to do the same with `./x.py doc --stage 2`. Might this be related to the recent change to x.py about how the doc is built?~~
2020-08-08Rollup merge of #75224 - Aaron1011:fix/function-arguments-naked, r=AmanieuYuki Okushi-4/+6
Don't call a function in function-arguments-naked.rs Fixes #75096 It's U.B. to use anything other than inline assmebling in a naked function. Fortunately, the `#break` directive works fine without anything in the function body.
2020-08-08Eliminate the `SessionGlobals` from `librustc_ast`.Nicholas Nethercote-4/+4
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This means they are accessed via the `Session`, rather than via TLS. A few `Attr` methods and `librustc_ast` functions are now methods of `Session`. All of this required passing a `Session` to lots of functions that didn't already have one. Some of these functions also had arguments removed, because those arguments could be accessed directly via the `Session` argument. `contains_feature_attr()` was dead, and is removed. Some functions were moved from `librustc_ast` elsewhere because they now need to access `Session`, which isn't available in that crate. - `entry_point_type()` --> `librustc_builtin_macros` - `global_allocator_spans()` --> `librustc_metadata` - `is_proc_macro_attr()` --> `Session`
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