about summary refs log tree commit diff
path: root/src/test
AgeCommit message (Collapse)AuthorLines
2019-11-28Auto merge of #66642 - ecstatic-morse:promotion-in-const, r=eddybbors-29/+44
Create promoted MIR fragments for `const` and `static`s Resolves #65732. The previous strategy of removing `Drop` and `StorageDead` for promoted locals only worked for rvalue lifetime extension and only if no `loop`s were present. This PR applies the approach currently used for `fn` and `const fn`s to `const` and `statics`. This may have some performance impacts. r? @eddyb
2019-11-28Auto merge of #66603 - Nadrieril:fix-65413, r=varkorbors-7/+81
Fix #65413 #65413 was due to an oversight in `pat_constructor` that didn't check if a particular const value was maybe a slice/array const.
2019-11-28Auto merge of #66246 - matthewjasper:simplify-mem-cat, r=pnkfelixbors-25/+5
Simplify memory categorization With AST borrowck gone, mem_categorization can be simplified, a lot. * `cmt_` is now called `Place`. Most local variable names have been updated to reflect this, but the `cat_*` methods retain their names. * `MemCategorizationContext` no longer needs a `ScopeTree` and always needs an `InferCtxt`. * `Place` now uses a similar representation to `mir::Place` with a `Vec` of projections. * `Upvar` places don't include the implicit environment and capture derefs. These are now handled by `regionck` when needed. * Various types, methods and variants only used by AST borrowck have been removed. * `ExprUseVisitor` now lives in `rustc_typeck::expr_use_visitor`. * `MemCategorizationContext` and `Place` live in `rustc_typeck::mem_categorization`. * `Place` is re-exported in `rustc_typeck::expr_use_visitor` so that Clippy can access it. The loss of an error in `issue-4335.rs` is due to a change in capture inference in ill-formed programs. If any projection from a variable is moved from then we capture that variable by move, whether or not the place being moved from allows this. Closes #66270
2019-11-28Auto merge of #66294 - davidhewitt:const_fn_memoization, r=oli-obkbors-129/+55
Add memoization for const function evaluations When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism. With thanks to @oli-obk for mentoring me through this at RustFest Barcelona. r? @oli-obk
2019-11-27Rollup merge of #66800 - jyn514:combine-const-match-tests, r=Dylan-DPCTyler Mandry-22/+11
Combine similar tests for const match See https://github.com/rust-lang/rust/pull/66788#issuecomment-558799307 for context.
2019-11-27Rollup merge of #66798 - bwignall:typo, r=varkorTyler Mandry-3/+3
Fix spelling typos Should be non-semantic. Uses https://en.wikipedia.org/wiki/Wikipedia:Lists_of_common_misspellings/For_machines to find likely typos.
2019-11-27Rollup merge of #66722 - matthewjasper:non_exhaustive_borrowck, r=varkorTyler Mandry-0/+83
Handle non_exhaustive in borrow checking Borrow check can tell whether a pattern is exhaustive or not, make sure that `non_exhaustive` prevents this.
2019-11-27Rollup merge of #66718 - VirrageS:use_comma, r=CentrilTyler Mandry-22/+57
Refactor `parse_enum_item` to use `parse_delim_comma_seq` Followup after https://github.com/rust-lang/rust/pull/66641 Some errors got more verbose but I think they make sense with the help message.
2019-11-27Rollup merge of #66704 - GuillaumeGomez:intra-doc-enum-variant-field, r=kinnisonTyler Mandry-0/+14
Intra doc enum variant field Part of #43466. Add intra-doc link support for this: ```rust enum Foo { X { y: u8, // can be found with Foo::X::y } } ``` r? @kinnison
2019-11-27Rollup merge of #66700 - VirrageS:master, r=matthewjasperTyler Mandry-0/+63
Fix pointing at arg for fulfillment errors in function calls Closes: https://github.com/rust-lang/rust/issues/66258
2019-11-27Rollup merge of #66305 - elichai:2019-11-array_ffi, r=eddybTyler Mandry-1/+33
Add by-value arrays to `improper_ctypes` lint Hi, C doesn't have a notion of passing arrays by value, only by reference/pointer. Rust currently will pass it correctly by reference by it looks very misleading, and can confuse the borrow checker to think a move had occurred. Fixes #58905 and fixes #24578. We could also improve the borrow checker here but I think it's kinda a waste of work if we instead just tell the user it's an invalid FFI call. (My first PR to `rustc` so if I missed some test or formatting guideline please tell me :) )
2019-11-27Rollup merge of #66222 - Aaron1011:fix/opaque-closure, r=pnkfelixTyler Mandry-0/+13
Use `eq_opaque_type_and_type` when type-checking closure signatures This handles the case where a user explicitly annotations a closure signature with a opaque return type. Fixes #63263
2019-11-27Rollup merge of #64325 - cramertj:nested-self-types, r=mikeyhewTyler Mandry-288/+166
Stabilize nested self receivers in 1.41.0 Previously, only `Self`, `&Self`, `&mut Self`, `Arc<Self>`, `Rc<Self>`, and `Box<Self>` were available as stable method receivers. This commit stabilizes nested uses of all the above types. However, nested receivers remain non-object-safe.
2019-11-27Simplify `mem_categorization`Matthew Jasper-25/+5
* `Place` is no longer recursive. * The `cmt` type alias is removed * `Upvar` places no longer include the dereferences of the environment closure or of by reference captures. * All non-dereference projections are combined to a single variant. * Various unnecessary types and methods have been removed.
2019-11-27Auto merge of #56231 - eddyb:mir-debuginfo, r=oli-obkbors-45/+193
rustc: move debug info from LocalDecl and UpvarDecl into a dedicated VarDebugInfo. This PR introduces a MIR "user variable" debuginfo system, which amounts to mapping a variable name, in some `SourceScope`, to a `Place`, so that: * each name can appear multiple times (e.g. due to macro hygiene), even in the same scope * each `Place` can appear multiple times (e.g. in the future from optimizations like NRVO, which collapse multiple MIR locals into one) * the `Place`s aren't limited to just locals, so they can describe the (right now quite ad-hoc) closure upvars and generator saved state fields, and can be properly transformed by optimizations (e.g. inlining - see `src/test/mir-opt/inline-closure-captures.rs`) The main motivation for this was that #48300 and further optimizations were blocked on being able to describe complex debuginfo transformations (see https://github.com/rust-lang/rust/pull/48300#discussion_r170020762). <hr/> In the textual representation, the "user variable" debuginfo can be found in each scope, and consists of `debug NAME => PLACE;` "declarations", e.g. the MIR for `let x = ...; let y = ...; ...` is now: ```rust let _1: T; // in scope 0 at ... scope 1 { debug x => _1; // in scope 1 at ... let _2: T; // in scope 1 at ... scope 2 { debug y => _2; // in scope 2 at ... } } ``` For reference, this is how the information was represented before this PR: (notably, the scopes in which the variables are visible for debuginfo weren't even shown anywhere, making `scope 2` look pointless, and user variable names were part of MIR locals) ```rust let _1: T; // "x" in scope 0 at ... scope 1 { let _2: T; // "y" in scope 1 at ... scope 2 { } } ``` cc @nikomatsakis @michaelwoerister
2019-11-27rustc: move debug info from LocalDecl and UpvarDecl into a dedicated ↵Eduard-Mihai Burtescu-45/+193
VarDebugInfo.
2019-11-27Auto merge of #66691 - dtolnay:fmt0, r=sfacklerbors-2/+2
Format libcore with rustfmt I am interested in whether we can begin cautious incremental progress on #66688 and assess along the way whether we can keep the disruption sufficiently small. This PR applies rustfmt with default settings to files in src/libcore *that are not involved in any currently open PR* to minimize merge conflicts. The list of files involved in open PRs was determined by querying GitHub's GraphQL API [with this script](https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8). With the list of files from the script in `outstanding_files`, the relevant commands were: ```console $ find src/libcore -name '*.rs' | xargs rustfmt --edition=2018 $ rg libcore outstanding_files | xargs git checkout -- ``` Repeating this process several months apart should get us coverage of most of the rest of libcore.
2019-11-27Add support for intra-doc link fields of enum variantGuillaume Gomez-0/+14
2019-11-27Add memoization for const function evaluationsDavid Hewitt-129/+55
When a const function is being evaluated, as long as all its arguments are zero-sized-types (or it has no arguments) then we can trivially memoize the evaluation result using the existing query mechanism.
2019-11-27Auto merge of #66677 - wesleywiser:fix_const_prop_alloc_id_ice, r=oli-obkbors-7/+31
[const prop] Fix "alloc id without corresponding allocation" ICE r? @oli-obk
2019-11-26Bless ui tests for libcore reformatDavid Tolnay-2/+2
2019-11-27Combine similar tests for const matchJoshua Nelson-22/+11
See https://github.com/rust-lang/rust/pull/66788#issuecomment-558799307 for context.
2019-11-27Auto merge of #66675 - GuillaumeGomez:support-anchors-intra-doc-links, ↵bors-28/+117
r=kinnison Support anchors intra doc links Fixes #62833 Part of #43466. cc @ollie27 r? @kinnison
2019-11-26Fix spelling typosBrian Wignall-3/+3
2019-11-26Rollup merge of #66788 - ecstatic-morse:const-fn-unreachable, r=CentrilTyler Mandry-0/+21
Allow `Unreachable` terminators through `min_const_fn` checks Resolves #66756. This allows `Unreachable` terminators through the `min_const_fn` checks if `#![feature(const_if_match)]` is enabled. We could probably just allow them with no feature flag, but it seems okay to be conservative here. r? @oli-obk
2019-11-26Rollup merge of #66786 - jyn514:const-if-match-tests, r=CentrilTyler Mandry-0/+21
Add wildcard test for const_if_match Closes https://github.com/rust-lang/rust/issues/66758 Many thanks to @Centril for his help getting me started!
2019-11-26Rollup merge of #66754 - estebank:rustdoc-capitalization, r=Dylan-DPCTyler Mandry-251/+72
Various tweaks to diagnostic output
2019-11-26Stabilize nested self receiversTaylor Cramer-288/+166
Previously, only Self, &Self, &mut Self, Arc<Self>, Rc<Self>, and Box<Self> were available as stable method receivers. This commit stabilizes nested uses of all the above types. However, nested receivers remain non-object-safe.
2019-11-26Remove test for #66758Dylan MacKenzie-6/+0
2019-11-26Add regression test for #66756Dylan MacKenzie-0/+27
2019-11-26Refactor 'parse_enum_item' to use 'parse_delim_comma_seq'Janusz Marcinkiewicz-22/+57
2019-11-26Test multiple variantsJoshua Nelson-0/+2
Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2019-11-26Auto merge of #66631 - michaelwoerister:additional-pgo-tests, r=alexcrichtonbors-0/+251
Add additional regression tests for PGO This PR adds regression tests for making sure that - instrumentation records the right counts for branches taken and functions called, and that - the indirect call promotion pass actually is able to promote indirect calls. r? @alexcrichton
2019-11-26PGO: Make branch-weights regression test more robust.Michael Woerister-10/+10
2019-11-26Auto merge of #66561 - TimoFreiberg:trait-name-report, r=estebankbors-7/+137
Add version mismatch help message for unimplemented trait Improves issue #22750 The error reporting for E0277 (the trait `X` is not implemented for `Foo`) now checks whether `Foo` implements a trait with the same path as `X`, which probably means that the programmer wanted to actually use only one version of the trait `X` instead of the two. Still open: * the same diagnostic should be added for [the trait method case](https://github.com/rust-lang/rust/issues/22750#issuecomment-372077056) * Showing the real crate versions would be nice, but rustc currently doesn't have that information [according to Esteban](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/diagnostics.20for.20crate.20version.20mismatch/near/180572989)
2019-11-26Auto merge of #66522 - tmiasko:sanitize-flags, r=alexcrichtonbors-0/+62
Add support for sanitizer recover and tracking origins of uninitialized memory * Add support for sanitizer recovery `-Zsanitizer-recover=...` (equivalent to `-fsanitize-recover` in clang). * Add support for tracking origins of uninitialized memory in MemorySanitizer `-Zsanitizer-memory-track-origins` (equivalent to `-fsanitize-memory-track-origins` in clang).
2019-11-25Add wildcard test for const_if_matchJoshua Nelson-0/+19
Closes https://github.com/rust-lang/rust/issues/66758
2019-11-25Auto merge of #66178 - Aaron1011:fix/opaque-normalize, r=varkorbors-41/+103
Fix opaque types resulting from projections in function signature When we normalize the types in a function signature, we may end up resolving a projection to an opaque type (e.g. `Self::MyType` when we have `type MyType = impl SomeTrait`). When the projection is resolved, we will instantiate the generic parameters into fresh inference variables. While we do want to normalize projections to opaque types, we don't want to replace the explicit generic parameters (e.g. `T` in `impl MyTrait<T>`) with inference variables. We want the opaque type in the function signature to be eligible to be a defining use of that opaque type - adding inference variables prevents this, since the opaque type substs now appears to refer to some specific type, rather than a generic type. To resolve this issue, we inspect the opaque types in the function signature after normalization. Any inference variables in the substs are replaced with the corresponding generic parameter in the identity substs (e.g. `T` in `impl MyTrait<T>`). Note that normalization is the only way that we can end up with inference variables in opaque substs in a function signature - users have no way of getting inference variables into a function signature. Note that all of this refers to the opaque type (ty::Opaque) and its subst - *not* to the underlying type. Fixes #59342
2019-11-25Tweak removed feature errorEsteban Küber-6/+2
2019-11-25Tweak bad `continue` errorEsteban Küber-7/+2
2019-11-25Tweak duplicate matcher binding errorEsteban Küber-28/+12
2019-11-25Tweak duplicate fmt arg errorEsteban Küber-7/+3
2019-11-25Tweak move error due to non-CopyEsteban Küber-168/+29
2019-11-25Tweak multiple allocators errorEsteban Küber-7/+4
2019-11-25Fix capitalization when mentioning different crate versions in E0308Esteban Küber-12/+4
2019-11-25Auto merge of #66739 - pietroalbini:rollup-2t2pd4a, r=pietroalbinibors-0/+33
Rollup of 7 pull requests Successful merges: - #65613 (Preserve whitespace inside one-backtick codeblocks) - #66512 (Add unix::process::CommandExt::arg0) - #66569 (GitHub Actions: preparations, part 1) - #66678 (Remove useless line for error index generation) - #66684 (Drive-by cleanup in region naming) - #66694 (Add some comments to panic runtime) - #66698 (tidy: Remove unused import) Failed merges: r? @ghost
2019-11-25Rollup merge of #66512 - jsgf:process-argv0, r=Dylan-DPCPietro Albini-0/+33
Add unix::process::CommandExt::arg0 This allows argv[0] to be overridden on the executable's command-line. This also makes the program executed independent of argv[0]. Does Fuchsia have the same semantics? I'm assuming so. Addresses: #66510
2019-11-25Update error messagesGuillaume Gomez-36/+36
2019-11-25Auto merge of #66682 - estebank:fn-type-err, r=davidtwcobors-34/+34
Highlight parts of fn in type errors When a type error arises between two fn items, fn pointers or tuples, highlight only the differing parts of each. Examples: <img width="699" alt="" src="https://user-images.githubusercontent.com/1606434/69487597-ab561600-0e11-11ea-9b4e-d4fd9e91d5dc.png"> <img width="528" alt="" src="https://user-images.githubusercontent.com/1606434/69487207-9033d800-0e0a-11ea-93e3-8c4d002411a5.png"> <img width="468" alt="" src="https://user-images.githubusercontent.com/1606434/69487208-9033d800-0e0a-11ea-92e3-2b2cee120335.png"> <img width="775" alt="" src="https://user-images.githubusercontent.com/1606434/69487209-9033d800-0e0a-11ea-9e68-7f6ed5c8cb08.png">
2019-11-25Auto merge of #66669 - petrochenkov:tup2attr, r=matthewjasperbors-0/+22
Fix some issues with attributes on unnamed fields Fixes https://github.com/rust-lang/rust/issues/66487 Fixes https://github.com/rust-lang/rust/issues/66555