about summary refs log tree commit diff
path: root/src
AgeCommit message (Collapse)AuthorLines
2020-10-17Make it more clear when complaining about async fn's return typesGus Wynn-100/+198
2020-10-17Auto merge of #77373 - jonas-schievink:rm-rf-copy-prop, r=oli-obkbors-96/+73
Remove the old copy propagation pass This pass was added a long time ago, and has not really seen much improvement since (apart from some great work in https://github.com/rust-lang/rust/pull/76569 that unfortunately ran into preexisting soundness issues). It is slow and unsound, and we now have a destination propagation pass that performs a related optimization and could be extended. Closes https://github.com/rust-lang/rust/issues/36673 Closes https://github.com/rust-lang/rust/issues/73717 Closes https://github.com/rust-lang/rust/issues/76740
2020-10-17Auto merge of #77124 - spastorino:const-exprs-rfc-2920, r=oli-obkbors-3/+97
Implement const expressions and patterns (RFC 2920) cc `@ecstatic-morse` `@lcnr` `@oli-obk` `@petrochenkov`
2020-10-17Auto merge of #77685 - jackh726:binder-map, r=lcnrbors-5/+9
Use rebind instead of Binder::bind when possible These are really only the easy places. I just searched for `Binder::bind` and replaced where it straightforward. r? `@lcnr` cc. `@nikomatsakis`
2020-10-17Auto merge of #76096 - pickfire:rustdoc-quote, r=jyn514bors-124/+131
Use double quote for rustdoc html r? `@GuillaumeGomez` Feels scary without escaping stuff when I looked at the code, probably susceptible to XSS. Follow up of https://github.com/rust-lang/rust/pull/75842
2020-10-17Fix some double quote that cause CI failureIvan Tham-3/+3
Co-authored-by: Oliver Middleton <olliemail27@gmail.com>
2020-10-17Auto merge of #78025 - ehuss:bump-bootstrap, r=Mark-Simulacrumbors-1/+1
Bump bootstrap compiler Mainly to bring in #77953 to fix https://github.com/rust-lang/cargo/issues/8517.
2020-10-17Rollup merge of #77985 - cuviper:systemz-agr-clobbers-cc, r=nikicDylan DPC-0/+0
llvm: backport SystemZ fix for AGR clobbers Fixes #77382.
2020-10-17Rollup merge of #77932 - ssomers:btree_cleanup_gdb, r=Mark-SimulacrumDylan DPC-19/+29
BTreeMap: improve gdb introspection of BTreeMap with ZST keys or values I accidentally pushed an earlier revision in #77788: it changes the index of tuples for BTreeSet from ""[{}]".format(i) to "key{}".format(i). Which doesn't seem to make the slightest difference on my linux box nor on CI. In fact, gdb doesn't make any distinction between "key{}" and "val{}" for a BTreeMap either, leading to confusing output if you test more. But easy to improve. r? @Mark-Simulacrum
2020-10-17Rollup merge of #77785 - GuillaumeGomez:remove-compiler-reexports, r=ollie27Dylan DPC-2/+16
Remove compiler-synthesized reexports when documenting Fixes #77567 r? @ollie27
2020-10-17Rollup merge of #76199 - Mark-Simulacrum:void-zero, r=nikomatsakisDylan DPC-10/+3
Permit uninhabited enums to cast into ints This essentially reverts part of #6204; it is unclear why that [commit](https://github.com/rust-lang/rust/pull/6204/commits/c0f587de34f30b060df8a88c4068740e587b9340) was introduced, and I suspect no one remembers. The changed code was only called from casting checks and appears to not affect any callers of that code (other than permitting this one case). Fixes #75647.
2020-10-17Remove the old copy propagation passJonas Schievink-96/+73
2020-10-16Add inline const to INCOMPLETE_FEATURESSantiago Pastorino-0/+4
2020-10-17Rollup merge of #78013 - GuillaumeGomez:fix-sidebar-scroll-mobile-devices, ↵Yuki Okushi-4/+0
r=jyn514 Fix sidebar scroll on mobile devices Fixes #77942. The issue was coming from the appearance/disappearance of the "wrapper" on the mobile devices web browsers, which triggers the "resize" event, calling the `hideSidebar` function is the JS code. r? @jyn514
2020-10-17Rollup merge of #77971 - jyn514:broken-intra-doc-links, r=mark-simulacrumYuki Okushi-0/+68
Deny broken intra-doc links in linkchecker Since rustdoc isn't warning about these links, check for them manually. This also fixes the broken links that popped up from the lint.
2020-10-17Rollup merge of #77925 - JohnTitor:sugg-min-features, r=davidtwco,oli-obkYuki Okushi-0/+87
Suggest minimal subset features in `incomplete_features` lint This tells users that we have a minimal subset feature of it and they can fix the lint warning without allowing it. The wording improvement is helpful :) Fixes #77913
2020-10-17Rollup merge of #77855 - ↵Yuki Okushi-23/+230
davidtwco:pr-77341-follow-up-non-constructable-variants, r=estebank resolve: further improvements to "try using the enum's variant" diagnostic Follow-up on https://github.com/rust-lang/rust/pull/77341#issuecomment-702738281. This PR improves the diagnostic modified in #77341 to suggest not only those variants which do not have fields, but those with fields (by suggesting with placeholders). In addition, the wording of the tuple-variant-only case is improved slightly. I've not made further changes to the tuple-variant-only case (e.g. to only suggest variants with the correct number of fields) because I don't think I have enough information to do so reliably (e.g. in the case where there is an attempt to construct a tuple variant, I have no information on how many fields were provided; and in the case of pattern matching, I only have a slice of spans and would need to check for things like `..` in those spans, which doesn't seem worth it). r? @estebank
2020-10-17Rollup merge of #77827 - jyn514:stable-primitives, r=GuillaumeGomezYuki Okushi-3/+8
Don't link to nightly primitives on stable channel I am not sure how to test this. Closes https://github.com/rust-lang/rust/issues/77775 r? @GuillaumeGomez
2020-10-17Rollup merge of #77547 - RalfJung:stable-union-drop, r=matthewjasperYuki Okushi-123/+67
stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union' As [discussed by @SimonSapin and @withoutboats](https://github.com/rust-lang/rust/issues/55149#issuecomment-634692020), this PR proposes to stabilize parts of the `untagged_union` feature gate: * It will be possible to have a union with field type `ManuallyDrop<T>` for any `T`. * While at it I propose we also stabilize `impl Drop for Union`; to my knowledge, there are no open concerns around this feature. In the RFC discussion, we also talked about allowing `&mut T` as another non-`Copy` non-dropping type, but that felt to me like an overly specific exception so I figured we'd wait if there is actually any use for such a special case. Some things remain unstable and still require the `untagged_union` feature gate: * Union with fields that do not drop, are not `Copy`, and are not `ManuallyDrop<_>`. The reason to not stabilize this is to avoid semver concerns around libraries adding `Drop` implementations later. (This is already not fully semver compatible as, to my knowledge, the borrow checker will exploit the non-dropping nature of any type, but it seems prudent to avoid further increasing the amount of trouble adding an `impl Drop` can cause.) Due to this, quite a few tests still need the `untagged_union` feature, but I think the ones where I could remove the feature flag provide good test coverage for the stable part. Cc @rust-lang/lang
2020-10-17Rollup merge of #75209 - Hirrolot:suggest-macro-imports, r=estebankYuki Okushi-0/+15
Suggest imports of unresolved macros Closes https://github.com/rust-lang/rust/issues/75191.
2020-10-16Handle ExprKind::ConstBlock on clippySantiago Pastorino-1/+17
2020-10-16Add inline const testsSantiago Pastorino-25/+55
2020-10-16Review commentsJack Huey-1/+1
2020-10-16Bump bootstrap compilerEric Huss-1/+1
2020-10-16map_bound_ref -> rebindJack Huey-10/+11
2020-10-16Parse inline const patternsSantiago Pastorino-2/+22
2020-10-16Parse inline const expressionsSantiago Pastorino-0/+10
2020-10-16Add inline_const feature flagSantiago Pastorino-0/+14
2020-10-16update miriRalf Jung-8/+10
2020-10-17Suggest minimal subset features in `incomplete_features` lintYuki Okushi-0/+87
2020-10-16Use map_bound(_ref) instead of Binder::bind when possibleJack Huey-7/+10
2020-10-17Use double quote for rustdoc htmlIvan Tham-126/+133
2020-10-16Auto merge of #77972 - Mark-Simulacrum:side-effect-loop, r=nagisabors-0/+15
Prevent miscompilation in trivial loop {} Ideally, we would want to handle a broader set of cases to fully fix the underlying bug here. That is currently relatively expensive at compile and runtime, so we don't do that for now. Performance results indicate this is not a major regression, if at all, so it should be safe to land. cc #28728
2020-10-16Fix sidebar scroll on mobile devicesGuillaume Gomez-4/+0
2020-10-16Auto merge of #77809 - nasso:master, r=jyn514,guillaumegomezbors-42/+240
Add settings to rustdoc to use the system theme This PR adds new settings to `rustdoc` to use the operating system color scheme. ![click](https://user-images.githubusercontent.com/11479594/95668052-bf604e80-0b6e-11eb-8a17-473aaae510c9.gif) `rustdoc` actually had [basic support for this](https://github.com/rust-lang/rust/blob/b1af43bc63bc7417938df056f7f25d456cc11b0e/src/librustdoc/html/static/storage.js#L121), but the setting wasn't visible and couldn't be set back once the theme was explicitly set by the user. It also didn't update if the operating system theme preference changed while viewing a page. I'm using [this method](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Testing_media_queries#Receiving_query_notifications) to query and listen to changes to the `(prefers-color-scheme: dark)` media query. I kept the old method (based on `getComputedStyle`) as a fallback in case the user-agent doesn't support `window.matchMedia` (so like... [pretty much nobody](https://caniuse.com/?search=matchMedia)). Since there's now more than one official ""dark"" theme in `rustdoc` (and also to support custom/third-party themes), the preferred dark and light themes can be configured in the settings page (the defaults are just "dark" and "light"). This is also my very first "proper" PR to Rust! Please let me know if I did anything wrong :).
2020-10-16stabilize union with 'ManuallyDrop' fields and 'impl Drop for Union'Ralf Jung-123/+67
2020-10-16Auto merge of #77947 - tmiasko:promoted-scope, r=oli-obkbors-2/+0
Create a single source scope for promoteds A promoted inherits all scopes from the parent body. At the same time, almost all statements and terminators inside the promoted body so far refer only to one of those scopes: the outermost one. Instead of inheriting all scopes, inherit only a single scope corresponding to the location of the promoted, making sure that there are no references to other scopes.
2020-10-15Update submodules for link fixesJoshua Nelson-0/+0
- [rust-embedded](https://github.com/rust-embedded/book/compare/79ab7776929c66db83203397958fa7037d5d9a30...ca8169e69b479f615855d0eece7e318138fcfc00) - [cargo](https://github.com/rust-lang/cargo/compare/12db56cdedbc2c26a9aa18f994c0188cdcc67df5...79b397d72c557eb6444a2ba0dc00a211a226a35a)
2020-10-15Deny broken intra-doc links in linkcheckerJoshua Nelson-0/+68
Since rustdoc isn't warning about these links, check for them manually.
2020-10-16Rollup merge of #77672 - Nemo157:simplify-cfg, r=jyn514Dylan DPC-52/+334
Simplify doc-cfg rendering based on the current context For sub-items on a page don't show cfg that has already been rendered on a parent item. At its simplest this means not showing anything that is shown in the portability message at the top of the page, but also for things like fields of an enum variant if that variant itself is cfg-gated then don't repeat those cfg on each field of the variant. This does not touch trait implementation rendering, as that is more complex and there are existing issues around how it deals with doc-cfg that need to be fixed first. ### Screenshots, left is current, right is new: ![image](https://user-images.githubusercontent.com/81079/95387261-c2e6a200-08f0-11eb-90d4-0a9734acd922.png) ![image](https://user-images.githubusercontent.com/81079/95387458-06411080-08f1-11eb-81f7-5dd7f37695dd.png) ![image](https://user-images.githubusercontent.com/81079/95387702-6637b700-08f1-11eb-82f4-46b6cd9b24f2.png) ![image](https://user-images.githubusercontent.com/81079/95387905-b9aa0500-08f1-11eb-8d95-8b618d31d419.png) ![image](https://user-images.githubusercontent.com/81079/95388300-5bc9ed00-08f2-11eb-9ac9-b92cbdb60b89.png) cc #43781
2020-10-16Rollup merge of #77493 - ↵Dylan DPC-7/+21
hosseind88:ICEs_should_always_print_the_top_of_the_query_stack, r=oli-obk ICEs should always print the top of the query stack see #76920
2020-10-16Rollup merge of #76119 - Amjad50:stabilizing-move_ref_pattern, r=nikomatsakisDylan DPC-422/+264
Stabilize move_ref_pattern # Implementation - Initially the rule was added in the run-up to 1.0. The AST-based borrow checker was having difficulty correctly enforcing match expressions that combined ref and move bindings, and so it was decided to simplify forbid the combination out right. - The move to MIR-based borrow checking made it possible to enforce the rules in a finer-grained level, but we kept the rule in place in an effort to be conservative in our changes. - In #68376, @Centril lifted the restriction but required a feature-gate. - This PR removes the feature-gate. Tracking issue: #68354. # Description This PR is to stabilize the feature `move_ref_pattern`, which allows patterns containing both `by-ref` and `by-move` bindings at the same time. For example: `Foo(ref x, y)`, where `x` is `by-ref`, and `y` is `by-move`. The rules of moving a variable also apply here when moving *part* of a variable, such as it can't be referenced or moved before. If this pattern is used, it would result in *partial move*, which means that part of the variable is moved. The variable that was partially moved from cannot be used as a whole in this case, only the parts that are still not moved can be used. ## Documentation - The reference (rust-lang/reference#881) - Rust by example (rust-lang/rust-by-example#1377) ## Tests There are many tests, but I think one of the comperhensive ones: - [borrowck-move-ref-pattern-pass.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern-pass.rs) - [borrowck-move-ref-pattern.rs](https://github.com/Centril/rust/blob/85fbf49ce0e2274d0acf798f6e703747674feec3/src/test/ui/pattern/move-ref-patterns/borrowck-move-ref-pattern.rs) # Examples ```rust #[derive(PartialEq, Eq)] struct Finished {} #[derive(PartialEq, Eq)] struct Processing { status: ProcessStatus, } #[derive(PartialEq, Eq)] enum ProcessStatus { One, Two, Three, } #[derive(PartialEq, Eq)] enum Status { Finished(Finished), Processing(Processing), } fn check_result(_url: &str) -> Status { // fetch status from some server Status::Processing(Processing { status: ProcessStatus::One, }) } fn wait_for_result(url: &str) -> Finished { let mut previous_status = None; loop { match check_result(url) { Status::Finished(f) => return f, Status::Processing(p) => { match (&mut previous_status, p.status) { (None, status) => previous_status = Some(status), // first status (Some(previous), status) if *previous == status => {} // no change, ignore (Some(previous), status) => { // Now it can be used // new status *previous = status; } } } } } } ``` Before, we would have used: ```rust match (&previous_status, p.status) { (Some(previous), status) if *previous == status => {} // no change, ignore (_, status) => { // new status previous_status = Some(status); } } ``` Demonstrating *partial move* ```rust fn main() { #[derive(Debug)] struct Person { name: String, age: u8, } let person = Person { name: String::from("Alice"), age: 20, }; // `name` is moved out of person, but `age` is referenced let Person { name, ref age } = person; println!("The person's age is {}", age); println!("The person's name is {}", name); // Error! borrow of partially moved value: `person` partial move occurs //println!("The person struct is {:?}", person); // `person` cannot be used but `person.age` can be used as it is not moved println!("The person's age from person struct is {}", person.age); } ```
2020-10-16Rollup merge of #76084 - Lucretiel:split-buffered, r=dtolnayDylan DPC-3/+3
Refactor io/buffered.rs into submodules This pull request splits `BufWriter`, `BufReader`, `LineWriter`, and `LineWriterShim` (along with their associated tests) into separate submodules. It contains no functional changes. This change is being made in anticipation of adding another type of buffered writer which can be switched between line- and block-buffering mode. Part of a series of pull requests resolving #60673.
2020-10-16Rollup merge of #75675 - davidtwco:symbol-mangling-impl-params, r=eddybDylan DPC-0/+98
mangling: mangle impl params w/ v0 scheme This PR modifies v0 symbol mangling to include all generic parameters from impl blocks (not just those used in the self type) - an alternative fix to #75326. ``` original: _RNCNvXCs4fqI2P2rA04_19impl_param_manglingINtB4_3FooppENtNtNtNtCsfnEnqCNU58Z_4core4iter6traits8iterator8Iterator4next0B4_ // |------------ B4_ ----------------| // _R (N C (N v (X (C ((s 4fqI2p2rA04_) 19impl_param_mangling)) (I (N t B4_ 3Foo) pp E) (N t (N t (N t (N t (C ((s fnEnqCNU58Z_) 4core)) 4iter) 6traits) 8iterator) 8Iterator)) 4next) 0) B4_ modified: _RNvXINICs4fqI2P2rA04_11issue_753260pppEINtB5_3FooppENtNtNtNtCsfnEnqCNU58Z_4core4iter6traits8iterator8Iterator4nextB5_ // _R (N v (X (I (N I (C ((s 4fqI2P2rA04_) 11issue_75326)) 0) ppp E) (I (N t B5_ 3Foo) pp E) (N t (N t (N t (N t (C ((s fnEnqCNU58Z_) 4core)) 4iter) 6traits) 8iterator) 8Iterator)) 4next) B5_ // | ^ | // | | | // | new impl namespace | ``` ~~Submitted as a draft as after some discussion w/ @eddyb, I'm going to do some investigation into (yet more alternative) changes to polymorphization that might remove the necessity for this.~~ r? @eddyb
2020-10-16Rollup merge of #75023 - euclio:argument-span, r=estebankDylan DPC-114/+222
ensure arguments are included in count mismatch span The current diagnostic isn't very helpful if the function header spans multiple lines. Lines comprising the function signature may be elided to keep the diagnostic short, but these lines are essential to fixing the error. This is made worse when the function has a body, because the last two lines of the span are then dedicated to showing the end of the body, which is irrelevant. This PR changes the span to be a multispan made up of the header and the the arguments, ensuring they won't be elided. It also discards the function body from the span. [Old](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f92d9f81a8c9416f0f04e4e09923b6d4): ``` error[E0061]: this function takes 6 arguments but 1 argument was supplied --> src/main.rs:18:5 | 1 | / fn bar( 2 | | a: i32, 3 | | b: i32, 4 | | c: i32, ... | 14 | | println!("{}", f); 15 | | } | |_- defined here ... 18 | bar(1); | ^^^ - supplied 1 argument | | | expected 6 arguments ``` New: ``` error[E0061]: this function takes 6 arguments but 1 argument was supplied --> $DIR/not-enough-arguments.rs:28:3 | LL | bar(1); | ^^^ - supplied 1 argument | | | expected 6 arguments | note: function defined here --> $DIR/not-enough-arguments.rs:9:1 | LL | / fn bar( LL | | a: i32, | | ^^^^^^^ LL | | b: i32, | | ^^^^^^^ LL | | c: i32, | | ^^^^^^^ LL | | d: i32, | | ^^^^^^^ LL | | e: i32, | | ^^^^^^^ LL | | f: i32, | | ^^^^^^^ LL | | ) { | |_^ ```
2020-10-15Auto merge of #77981 - GuillaumeGomez:rollup-64ydc5g, r=GuillaumeGomezbors-0/+8
Rollup of 3 pull requests Successful merges: - #77963 (Fix link to foreign calling conventions) - #77978 (Fix typo in documentation) - #77979 (Hide help button on mobile) Failed merges: r? `@ghost`
2020-10-15llvm: backport SystemZ fix for AGR clobbersJosh Stone-0/+0
2020-10-15resolve: improve "try using tuple struct" messageDavid Wood-5/+5
This commit improves the tuple struct case added in rust-lang/rust#77341 so that the context is mentioned in more of the message. Signed-off-by: David Wood <david@davidtw.co>
2020-10-15resolve: suggest variants with placeholdersDavid Wood-18/+225
This commit improves the diagnostic modified in rust-lang/rust#77341 to suggest not only those variants which do not have fields, but those with fields (by suggesting with placeholders). Signed-off-by: David Wood <david@davidtw.co>
2020-10-15Auto merge of #77943 - est31:target_refactor, r=petrochenkovbors-3/+3
No more target.target Two main changes of this PR: * Turn `target_pointer_width` into an integer and rename to `pointer_width`. The compiler only allowed three valid values for the width anyways. An integer is more natural for this value, and saves a few allocations and copies. * Remove the `rustc_session::config::Config` wrapper and replace it with its inner member `Target`. Aka. no more `target.target`. This makes life so much easier, but it also causes a ton of downstream breakage. Some changes of this PR were done using tooling. These tooling-made changes were isolated to their own commits to make review easier. It's best to review the PR commit-by-commit. Miri PR: https://github.com/rust-lang/miri/pull/1583 I request p=10 bors priority because of the breakage.