about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2020-02-15Formatter::sign is &'static strMark Rousskov-21/+21
The contents were always UTF-8 anyway, and &str has an equivalent representation to &[u8], so this should not affect performance while removing unsafety at edges. It may be worth exploring a further adjustment that stores a single byte (instead of 16) as the contents are always "", "-", or "+".
2020-02-15Auto merge of #69168 - brainlock:test-textrel-regression, ↵bors-0/+31
r=Mark-Simulacrum,tmandry add regression test for issue #68794 This is a minimal regression test for the issue #68794: "TEXTREL in i686", which was fixed with e86019c4a0968a1e393cdd0731649168624a88b8. The test links a minimal rust static library into a shared library, and checks that the linker didn't have to add the TEXTREL flag.
2020-02-15Rollup merge of #69180 - Aaron1011:feature/comma-struct-init, r=petrochenkovDylan DPC-3/+46
Suggest a comma if a struct initializer field fails to parse Currently, we emit a "try adding a comma" suggestion if a comma is missing in a struct definition. However, we emit no such suggestion if a comma is missing in a struct initializer. This commit adds a "try adding a comma" suggestion when we don't find a comma during the parsing of a struct initializer field. The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't great, but I don't see a good way of avoiding it.
2020-02-15Rollup merge of #69166 - JohnTitor:ice-const-enum, r=matthewjasperDylan DPC-1/+19
Check `has_typeck_tables` before calling `typeck_tables_of` Fixes #68684 r? @matthewjasper
2020-02-15Rollup merge of #69154 - JohnTitor:fix-macro-ices, r=petrochenkovDylan DPC-2/+42
Avoid calling `fn_sig` on closures Fixes #68060 r? @petrochenkov
2020-02-15Rollup merge of #69106 - RReverser:wasi-fs-copy, r=KodrAusDylan DPC-1/+9
Fix std::fs::copy on WASI target Previously `std::fs::copy` on wasm32-wasi would reuse code from the `sys_common` module and would successfully copy contents of the file just to fail right before closing it. This was happening because `sys_common::copy` tries to copy permissions of the file, but permissions are not a thing in WASI (at least yet) and `set_permissions` is implemented as an unconditional runtime error. This change instead adds a custom working implementation of `std::fs::copy` (like Rust already has on some other targets) that doesn't try to call `set_permissions` and is essentially a thin wrapper around `std::io::copy`. Fixes #68560.
2020-02-15Rollup merge of #66721 - maxbla:exp-format-integers, r=KodrAusDylan DPC-0/+243
implement LowerExp and UpperExp for integers Addresses https://github.com/rust-lang/rust/issues/39479 This implementation is heavily based on the preexisting `macro_rules! impl_Display` in the same file. I don't like the liberal use of unsafe in that macro and would like to modify it so `unsafe` is only present where necessary. What is Rust's policy on doing such modifications? Also, I couldn't figure out where to put tests, can I have some help with that?
2020-02-15Rollup merge of #64069 - ↵Dylan DPC-0/+28
danielhenrymantilla:feature/cstring_from_vec_of_nonzerou8, r=KodrAus Added From<Vec<NonZeroU8>> for CString Added a `From<Vec<NonZeroU8>>` `impl` for `CString` # Rationale - `CString::from_vec_unchecked` is a subtle function, that makes `unsafe` code harder to audit when the generated `Vec`'s creation is non-trivial. This `impl` allows to write safer `unsafe` code thanks to the very explicit semantics of the `Vec<NonZeroU8>` type. - One such situation is when trying to `.read()` a `CString`, see issue #59229. - this lead to a PR: #59314, that was closed for being too specific / narrow (it only targetted being able to `.read()` a `CString`, when this pattern could have been generalized). - the issue suggested another route, based on `From<Vec<NonZeroU8>>`, which is indeed a less general and more concise code pattern. - quoting @shnatsel: - > For me the main thing about making this safe is simplifying auditing - people have spent like an hour looking at just this one unsafe block in libflate because it's not clear what exactly is unchecked, so you have to look it up when auditing anyway. This has distracted us from much more serious memory safety issues the library had. Having this trivial impl in stdlib would turn this into safe code with compiler more or less guaranteeing that it's fine, and save anyone auditing the code a whole lot of time.
2020-02-14Suggest a comma if a struct initializer field fails to parseAaron Hill-3/+46
Currently, we emit a "try adding a comma" suggestion if a comma is missing in a struct definition. However, we emit no such suggestion if a comma is missing in a struct initializer. This commit adds a "try adding a comma" suggestion when we don't find a comma during the parsing of a struct initializer field. The change to `src/test/ui/parser/removed-syntax-with-1.stderr` isn't great, but I don't see a good way of avoiding it.
2020-02-14implement LowerExp and UpperExp for integersMax Blachman-0/+243
2020-02-15Auto merge of #67681 - matthewjasper:infer-regions-in-borrowck, r=nikomatsakisbors-1304/+1996
Infer regions for opaque types in borrowck This is a step towards the goal of typeck not doing region inference. The commits up to `Arena allocate the result of mir_borrowck` are various bug fixes and prerequisites. The remaining commits move opaque type inference to borrow checking. r? @nikomatsakis
2020-02-14Auto merge of #69172 - JohnTitor:rollup-6cbmwcw, r=JohnTitorbors-189/+703
Rollup of 7 pull requests Successful merges: - #68129 (Correct inference of primitive operand type behind binary operation) - #68475 (Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`) - #68856 (typeck: clarify def_bm adjustments & add tests for or-patterns) - #69051 (simplify_try: address some of eddyb's comments) - #69128 (Fix extra subslice lowering) - #69150 (Follow-up to #68848) - #69164 (Update pulldown-cmark dependency) Failed merges: r? @ghost
2020-02-14Fix tests after rebaseMatthew Jasper-51/+82
2020-02-14Split `type_of` out of collect.rsMatthew Jasper-653/+666
2020-02-14Add fast path to eq_opaque_type_and_typeMatthew Jasper-3/+25
2020-02-14Fix and test nested impl TraitMatthew Jasper-5/+29
2020-02-14Update testsMatthew Jasper-231/+124
2020-02-14Use member constraint for most opaque types in NLLMatthew Jasper-15/+43
This ensures that NLL will infer suitable values for regions in opaque types when it's possible.
2020-02-14Always check upper bounds when choosing member regionsMatthew Jasper-40/+81
Also correctly calculate what the upper bounds are.
2020-02-14Improve opaque type lifetime errorsMatthew Jasper-31/+41
* Use better span for member constraint errors * Avoid a bad suggestion * Don't report member constraint errors if we have other universal region errors.
2020-02-14Handle equal regions in opaque type inferenceMatthew Jasper-18/+127
2020-02-14Show inferred opaque types with `#[rustc_regions]`Matthew Jasper-5/+29
2020-02-14Address review commentsMatthew Jasper-55/+67
2020-02-14Update testsMatthew Jasper-157/+291
2020-02-14Erase regions in opaque types in typeckMatthew Jasper-27/+65
2020-02-14Ensure RPIT types get recorded in borrowckMatthew Jasper-7/+27
2020-02-14Avoid unnecessary opaque type errors in borrowckMatthew Jasper-0/+8
2020-02-14Infer opaque type regions in borrow checkingMatthew Jasper-3/+83
We want type checking for function bodies to ignore/erase regions. As such, we need to infer the regions in opaque types in borrow check instead.
2020-02-14Prepare to use borrowck to resolve opaque typesMatthew Jasper-68/+128
2020-02-14Arena allocate the result of mir_borrowckMatthew Jasper-13/+12
2020-02-14Generate more accurate MIR in `construct_error`Matthew Jasper-5/+42
2020-02-15Avoid calling `fn_sig` on closuresYuki Okushi-2/+42
2020-02-15Rollup merge of #69164 - GuillaumeGomez:update-pulldown-cmark, r=Dylan-DPCYuki Okushi-76/+96
Update pulldown-cmark dependency r? @kinnison cc @ollie27 Reopening of #65894.
2020-02-15Rollup merge of #69150 - nnethercote:68848-follow-up, r=petrochenkovYuki Okushi-17/+15
Follow-up to #68848 This PR contains some late changes to #68848 that somehow didn't get included when that PR was merged in a roll-up. r? @petrochenkov
2020-02-15Rollup merge of #69128 - Centril:fix-69103, r=davidtwcoYuki Okushi-6/+55
Fix extra subslice lowering We are currently ICEing on e.g. ```rust fn main() { let [.., b @ ..] = [1, 2]; b; } ``` This happens because `b @ ..` registers a binding such that `b;` is OK, but then we forget to lower that binding in `rustc_ast_lowering`. Fixes #69103. r? @davidtwco
2020-02-15Rollup merge of #69051 - Centril:st-fixes, r=eddybYuki Okushi-0/+3
simplify_try: address some of eddyb's comments Addresses only https://github.com/rust-lang/rust/pull/66282#discussion_r376730986 and https://github.com/rust-lang/rust/pull/66282#discussion_r376730824. r? @eddyb cc @oli-obk
2020-02-15Rollup merge of #68856 - Centril:or-pat-ref-pat, r=matthewjasperYuki Okushi-62/+447
typeck: clarify def_bm adjustments & add tests for or-patterns Clarify the adjustment algorithm for the expected type / default binding-modes when type checking patterns with more documentation and tweaks that make the algorithm more independent of the pattern forms. Also resolve the FIXME noted for or-patterns by deciding that the current implementation is correct, noting the rationale and adding tests for the current implementation. cc https://github.com/rust-lang/rust/issues/54883 r? @oli-obk @varkor
2020-02-15Rollup merge of #68475 - Aaron1011:fix/forest-caching, r=nikomatsakisYuki Okushi-18/+26
Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest` Previously, we used a plain `Predicate` to cache results (e.g. successes and failures) in ObligationForest. However, fulfillment depends on the precise `ParamEnv` used, so this is unsound in general. This commit changes the impl of `ForestObligation` for `PendingPredicateObligation` to use `ParamEnvAnd<Predicate>` instead of `Predicate` for the associated type. The associated type and method are renamed from 'predicate' to 'cache_key' to reflect the fact that type is no longer just a predicate.
2020-02-15Rollup merge of #68129 - varkor:infer-binary-operand-behind-reference, ↵Yuki Okushi-10/+61
r=nikomatsakis Correct inference of primitive operand type behind binary operation Fixes https://github.com/rust-lang/rust/issues/57447. r? @nikomatsakis
2020-02-14Update pulldown-cmark dependencyGuillaume Gomez-76/+96
2020-02-14Simplify function signature in opaque_typesMatthew Jasper-9/+5
2020-02-14Give some more queries descriptionsMatthew Jasper-1/+6
2020-02-14Distinguish RPIT from other impl traitMatthew Jasper-20/+39
2020-02-14Call `is_freeze` less in unsafety-checkingMatthew Jasper-19/+58
This is to avoid cycles when calling `is_freeze` on an opaque type.
2020-02-14Check associated opaque types don't use unconstrained lifetimesMatthew Jasper-14/+57
2020-02-14Explain a testMatthew Jasper-2/+9
2020-02-14Auto merge of #69115 - ehuss:update-books, r=Dylan-DPCbors-31/+90
Update books. This required some changes in how the books are tested due to some changes in rust-lang/book. It uses new syntax that is not compatible with bare `rustdoc --test`. This changes it so that it uses rustbook to run the tests, which is essentially the same as `mdbook test`. ## reference 7 commits in 11e893fc1357bc688418ddf1087c2b7aa25d154d..64239df6d173562b9deb4f012e4c3e6e960c4754 2020-01-18 21:24:08 +0100 to 2020-02-10 19:05:13 +0100 - Update for nested receivers. (rust-lang-nursery/reference#724) - clarify note re. leading `::` in 2018 (rust-lang-nursery/reference#752) - Update macro-ambiguity.md (rust-lang-nursery/reference#754) - typo fix: add missing `by` (rust-lang-nursery/reference#753) - fix `TypeParamBounds` link on trait objects (rust-lang-nursery/reference#749) - reorganize docs on references (rust-lang-nursery/reference#745) - add MacroRepOp usage for ? (rust-lang-nursery/reference#744) ## book 49 commits in 87dd6843678575f8dda962f239d14ef4be14b352..6fb3705e5230311b096d47f7e2c91f9ce24393d0 2020-01-20 15:20:40 -0500 to 2020-02-12 13:48:57 -0500 - Fix nomicon links. (rust-lang/book#2253) - Update to Rust 1.41.0 (rust-lang/book#2244) - Listing 19-6: use ptr.add instead of ptr.offset (rust-lang/book#2201) - Remove unneeded mutable reference - Clarify deref coercion explanation - Fix typo in link to 1.30 book - Acknowledge Murphy's Law - Clarify that buffer overread is UB in C - Change from "must" to "idiomatic" about comments - Fancy quotes - Make HashMap types match previous example; add fwd ref to ch 13 - Tweak wording to array clarification - Merge remote-tracking branch 'origin/pr/2236' - Update all our crates (rust-lang/book#2235) - Reword git caveat - Merge remote-tracking branch 'origin/pr/2234' - Merge remote-tracking branch 'origin/pr/2230' - println! is a macro (rust-lang/book#2224) - Update a translated version link (rust-lang/book#2221) - move `Macro invocation` from section on tuple to section on mac… (rust-lang/book#2206) - Do not limit `Self` usage in trait implementation (rust-lang/book#2197) - Merge remote-tracking branch 'origin/pr/2191' - Fix wrapping - Merge remote-tracking branch 'origin/pr/2187' - Updated appendix 07 to reflect deprecation of rustup install (rust-lang/book#2181) - Make links to the Nomicon consistent - Merge remote-tracking branch 'origin/pr/2180' - Merge remote-tracking branch 'origin/pr/2175' - Merge remote-tracking branch 'origin/pr/2171' - Merge remote-tracking branch 'origin/pr/2170' - Clarify and make consistent the explanation of unions - Merge remote-tracking branch 'origin/pr/2166' - Handle dev or test in the Finished output line - Link to macros by example rather than macros (rust-lang/book#2164) - Merge remote-tracking branch 'origin/pr/2147' - Fix parens (rust-lang/book#2132) - Clarify type inference with closures requires calling the closures - Update link to French translation (rust-lang/book#2119) - Merge remote-tracking branch 'origin/pr/2108' - Add an explicit cross reference to data type - Merge remote-tracking branch 'origin/pr/2105' - ch15-02-deref: Improve explanation on immut-to-mut (rust-lang/book#2030) - Remove unnecessary quotes - Make markdown link identifier match - Remove extra newline - Merge remote-tracking branch 'origin/pr/2004' - Extract code and output; script formatting and updating them (rust-lang/book#2231) - Switch "Finally" to "Next" to reflect new chapters having been… (rust-lang/book#2098) - ch19-06 added curly braces to macro output (rust-lang/book#2050) ## rust-by-example 2 commits in 1c2bd024d13f8011307e13386cf1fea2180352b5..32facd5522ddbbf37baf01e4e4b6562bc55c071a 2020-01-20 12:18:36 -0300 to 2020-02-11 09:25:06 -0300 - Add missing `dyn` in code sample (rust-lang/rust-by-example#1306) - Improve grammar in a few sections (rust-lang/rust-by-example#1305) ## edition-guide 1 commits in 1a2390247ad6d08160e0dd74f40a01a9578659c2..37f9e6848411188a1062ead1bd8ebe4b8aa16899 2019-12-29 10:40:55 -0800 to 2020-02-10 14:36:14 +0100 - Fixed typo (rust-lang-nursery/edition-guide#196) ## embedded-book 4 commits in 4d78994915af1bde9a95c04a8c27d8dca066232a..b2e1092bf67bd4d7686c4553f186edbb7f5f92db 2020-01-14 08:25:25 +0000 to 2020-01-30 08:45:46 +0000 - Make typestate initialization notes correct (rust-embedded/book#224) - Mention discovery book more prominently (rust-embedded/book#219) - Replace nursery links with rust-lang links (rust-embedded/book#222) - Add a Glossary appendix page (rust-embedded/book#223)
2020-02-14Auto merge of #69100 - cjgillot:resolve_instance, r=Zoxcbors-123/+160
Move resolve_instance to rustc_ty. r? @Zoxc
2020-02-14add regression test for issue #68794Alberto Piai-0/+31
This is a minimal regression test for the issue #68794: "TEXTREL in i686", which was fixed with e86019c4a0968a1e393cdd0731649168624a88b8. The test links a minimal rust static library into a shared library, and checks that the linker didn't have to add the TEXTREL flag.
2020-02-14Check `has_typeck_tables` before calling `typeck_tables_of`Yuki Okushi-1/+19