- 24 8月, 2020 40 次提交
-
-
由 Aleksey Kladov 提交于
Snapshot testing is a technique for writing maintainable unit tests. Unlike usual `assert_eq!` tests, snapshot tests allow to *automatically* upgrade expected values on test failure. In a sense, snapshot tests are inline-version of our beloved UI-tests. Example: ![expect](https://user-images.githubusercontent.com/1711539/90888810-3bcc8180-e3b7-11ea-9626-d06e89e1a0bb.gif) A particular library we use, `expect_test` provides an `expect!` macro, which creates a sort of self-updating string literal (by using `file!` macro). Self-update is triggered by setting `UPDATE_EXPECT` environmental variable (this info is printed during the test failure). This library was extracted from rust-analyzer, where we use it for most of our tests. There are some other, more popular snapshot testing libraries: * https://github.com/mitsuhiko/insta * https://github.com/aaronabramov/k9 The main differences of `expect` are: * first-class snapshot objects (so, tests can be written as functions, rather than as macros) * focus on inline-snapshots (but file snapshots are also supported) * restricted feature set (only `assert_eq` and `assert_debug_eq`) * no extra runtime (ie, no `cargo insta`) See https://github.com/rust-analyzer/rust-analyzer/pull/5101 for a an extended comparison. It is unclear if this testing style will stick with rustc in the long run. At the moment, rustc is mainly tested via integrated UI tests. But in the library-ified world, unit-tests will become somewhat more important (that's why use use `rustc_lexer` library-ified library as an example in this PR). Given that the cost of removal shouldn't be too high, it probably makes sense to just see if this flies!
-
由 bors 提交于
Report an ambiguity if both modules and primitives are in scope for intra-doc links Closes https://github.com/rust-lang/rust/issues/75381 - Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case. I also need to update libstd to use `prim@char` instead of `type@char`. If possible I would also like to refactor `ambiguity_error` to use `Disambiguator` instead of its own hand-rolled match - that ran into issues with `prim@` (I updated one and not the other) and it would be better for them to be in sync.
-
由 bors 提交于
Add Arc::new_cyclic Rework of #72443 References #75861 cc @Diggsey @RalfJung r? @KodrAus
-
由 bors 提交于
Use allow(unused_imports) instead of cfg(doc) for imports used only for intra-doc links This prevents links from breaking when items are re-exported in a different crate and the original isn't being documented. Spotted in https://github.com/rust-lang/rust/pull/75832#discussion_r475275837 (thanks ollie!) r? @ollie27
-
由 bors 提交于
Rollup of 10 pull requests Successful merges: - #75819 (Use intra-doc-links in `core::{char, macros, fmt}`) - #75821 (Switch to intra-doc links in `std::macros`) - #75825 (Fix typo in documentation of i32 wrapping_abs()) - #75826 (Corrected Misleading documentation for derived Ord/PartialOrd implementation ) - #75831 (doc: Prefer https link for wikipedia URLs) - #75844 (publish-toolstate: show more context on HTTP error) - #75847 (Switch to intra-doc links in `std::collections`) - #75851 (Switch to intra-doc links in `core::array`) - #75856 (more tool clippy fixes) - #75859 (doc: Fix typo in std::process::Child documentation) Failed merges: r? @ghost
-
由 Joshua Nelson 提交于
-
由 Yuki Okushi 提交于
doc: Fix typo in std::process::Child documentation Nearly done reading stdlib docs, found another small typo, here's a PR! r? @steveklabnik
-
由 Yuki Okushi 提交于
more tool clippy fixes r? @Dylan-DPC
-
由 Yuki Okushi 提交于
Switch to intra-doc links in `core::array` Part of #75080. @rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
-
由 Yuki Okushi 提交于
Switch to intra-doc links in `std::collections` Part of #75080. @rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
-
由 Yuki Okushi 提交于
publish-toolstate: show more context on HTTP error The default display for HTTPError in Python does not include the request body. For GitHub API, the body includes more details about the error (like rate limiting). This could help diagnosing errors like this: https://github.com/rust-lang/rust/pull/75815#issuecomment-678798158
-
由 Yuki Okushi 提交于
doc: Prefer https link for wikipedia URLs A tiny changes.
-
由 Yuki Okushi 提交于
Rollup merge of #75826 - ayushmishra2005:misleading_documentation_for_derived_Ord_PartialOrd, r=KodrAus Corrected Misleading documentation for derived Ord/PartialOrd implementation Corrected Misleading documentation for derived Ord/PartialOrd implementation Fixes #75620
-
由 Yuki Okushi 提交于
Fix typo in documentation of i32 wrapping_abs() Hi! I was reading through the std library docs and noticed that this section flowed a bit oddly; comparing it against https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_div and https://doc.rust-lang.org/std/primitive.i32.html#method.wrapping_neg , I noticed that those two pieces of documentation used a semicolon here. This is my first time submitting a PR to this repo. Am I doing this right? Are tiny typo-fix PRs like this worth submitting, or are they not a good use of time? Thank you!
-
由 Yuki Okushi 提交于
Switch to intra-doc links in `std::macros` Part of #75080. --- * Switch to intra-doc links in `std::macros` * Fix typo in module docs * Link to `std::io::stderr` instead of `std::io::Stderr` to match the link text * Link to `std::io::stdout` --- @rustbot modify labels: A-intra-doc-links T-doc T-rustdoc
-
由 Yuki Okushi 提交于
Use intra-doc-links in `core::{char, macros, fmt}` Helps with #75080. r? @jyn514
-
由 Joshua Nelson 提交于
-
由 Joshua Nelson 提交于
-
由 Joshua Nelson 提交于
-
由 Joshua Nelson 提交于
-
由 Joshua Nelson 提交于
-
由 Joshua Nelson 提交于
This also changes human intuition -> intuition. 'human intuition' sounds vaguely menacing.
-
由 Joshua Nelson 提交于
- Add a new `prim@` disambiguator, since both modules and primitives are in the same namespace - Refactor `report_ambiguity` into a closure Additionally, I noticed that rustdoc would previously allow `[struct@char]` if `char` resolved to a primitive (not if it had a DefId). I fixed that and added a test case.
-
由 bors 提交于
Use intra-doc link in `proc_macro` Yep. One link. Helps with #75080. r? @jyn514
-
由 Dylan DPC 提交于
-
由 JR Heard 提交于
-
由 bors 提交于
Fix intra-doc links for associated items @Manishearth and I found that links of the following sort are broken: ```rust $ cat str_from.rs /// [`String::from`] pub fn foo() {} $ rustdoc str_from.rs warning: `[String::from]` cannot be resolved, ignoring it. --> str_from.rs:4:6 | 4 | /// [`String::from`] | ^^^^^^^^^^^^^^ cannot be resolved, ignoring ``` It turns out this is because the current implementation only looks at inherent impls (`impl Bar {}`) and traits _for the item being documented_. Note that this is not the same as the item being _linked_ to. So this code would work: ```rust pub trait T1 { fn method(); } pub struct S; impl T1 for S { /// [S::method] on method fn method() {} } ``` but putting the documentation on `trait T1` would not. ~~I realized that writing it up that my fix is only partially correct: It removes the inherent impls code when it should instead remove the `trait_item` code.~~ Fixed. Additionally, I discovered while writing this there is some ambiguity: you could have multiple methods with the same name, but for different traits: ```rust pub trait T1 { fn method(); } pub trait T2 { fn method(); } /// See [S::method] pub struct S; ``` Rustdoc should give an ambiguity error here, but since there is currently no way to disambiguate the traits (https://github.com/rust-lang/rust/issues/74563) it does not (https://github.com/rust-lang/rust/pull/74489#issuecomment-673878404). There is a _third_ ambiguity that pops up: What if the trait is generic and is implemented multiple times with different generic parameters? In this case, my fix does not do very well: it thinks there is only one trait instantiated and links to that trait: ``` /// [`String::from`] -- this resolves to https://doc.rust-lang.org/nightly/alloc/string/struct.String.html#method.from pub fn foo() {} ``` However, every `From` implementation has a method called `from`! So the browser picks a random one. This is not the desired behavior, but it's not clear how to avoid it. To be consistent with the rest of intra-doc links, this only resolves associated items from traits that are in scope. This required changes to rustc_resolve to work cross-crate; the relevant commits are prefixed with `resolve: `. As a bonus, considering only traits in scope is slightly faster. To avoid re-calculating the traits over and over, rustdoc uses a cache to store the traits in scope for a given module.
-
由 Matthias Krüger 提交于
-
由 Joshua Nelson 提交于
This prevents links from breaking when items are re-exported in a different crate and the original isn't being documented.
-
由 Matthias Krüger 提交于
unicode_table_generator: fix clippy::writeln_empty_string, clippy::useless_format, clippy:::for_kv_map
-
由 Matthias Krüger 提交于
-
由 LeSeulArtichaut 提交于
-
由 Matthias Krüger 提交于
-
由 Matthias Krüger 提交于
-
由 Joshua Nelson 提交于
-
由 Camelid 提交于
-
由 bors 提交于
Provide better spans for the match arm without tail expression Resolves #75418. Applied the same logic in the `if`-`else` type mismatch case. r? @estebank
-
由 Camelid 提交于
-
由 bors 提交于
Const floating point bitcasts and classification Makes the `f32` and `f64` methods described in #72447 and #72505 unstably const. r? @RalfJung
-
由 Eric Huss 提交于
-