diff options
| author | bors <bors@rust-lang.org> | 2022-12-24 10:46:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-24 10:46:43 +0000 |
| commit | 8766bbdc30a297aaa249193f5513fb261ccef17c (patch) | |
| tree | 4b6141e66c79bd3545e280cabe09e22cd3342dcb /src | |
| parent | 5e8bab91d339037388d152fd5066c26ae707d54e (diff) | |
| parent | 750bf73aea78a613456dc93f34cc32e43e9252f8 (diff) | |
| download | rust-8766bbdc30a297aaa249193f5513fb261ccef17c.tar.gz rust-8766bbdc30a297aaa249193f5513fb261ccef17c.zip | |
Auto merge of #106111 - matthiaskrgr:rollup-nnpoe5h, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #105465 (Improve top-level docs) - #105872 (Suggest remove last method call when type coerce with expected type) - #106032 (std: only use LFS function on glibc) - #106078 (Provide more context on FileCheck failures) - #106100 (Codegen test for derived `<` on trivial newtype [TEST ONLY]) - #106109 (rustdoc: make line number CSS for doc comment and scraped the same) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/README.md | 10 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 5 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/rustdoc.css | 30 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/themes/ayu.css | 3 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/themes/dark.css | 1 | ||||
| -rw-r--r-- | src/librustdoc/html/static/css/themes/light.css | 1 | ||||
| -rw-r--r-- | src/test/codegen/comparison-operators-newtype.rs | 49 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/docblock-code-block-line-number.goml | 54 | ||||
| -rw-r--r-- | src/test/rustdoc-gui/source-code-page.goml | 4 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-105494.rs | 22 | ||||
| -rw-r--r-- | src/test/ui/suggestions/issue-105494.stderr | 54 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 2 |
12 files changed, 184 insertions, 51 deletions
diff --git a/src/bootstrap/README.md b/src/bootstrap/README.md index 985727bddc5..79c2eb31cda 100644 --- a/src/bootstrap/README.md +++ b/src/bootstrap/README.md @@ -80,18 +80,12 @@ The script accepts commands, flags, and arguments to determine what to do: ## Configuring rustbuild -There are currently two methods for configuring the rustbuild build system. - -First, rustbuild offers a TOML-based configuration system with a `config.toml` +rustbuild offers a TOML-based configuration system with a `config.toml` file. An example of this configuration can be found at `config.toml.example`, and the configuration file can also be passed as `--config path/to/config.toml` if the build system is being invoked manually (via the python script). -Next, the `./configure` options serialized in `config.mk` will be -parsed and read. That is, if any `./configure` options are passed, they'll be -handled naturally. `./configure` should almost never be used for local -installations, and is primarily useful for CI. Prefer to customize behavior -using `config.toml`. +You can generate a config.toml using `./configure` options if you want to automate creating the file without having to edit it. Finally, rustbuild makes use of the [cc-rs crate] which has [its own method][env-vars] of configuring C compilers and C flags via environment diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 84278583846..b41d60d51a8 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -49,10 +49,7 @@ pub enum DryRun { /// Global configuration for the entire build and/or bootstrap. /// -/// This structure is derived from a combination of both `config.toml` and -/// `config.mk`. As of the time of this writing it's unlikely that `config.toml` -/// is used all that much, so this is primarily filled out by `config.mk` which -/// is generated from `./configure`. +/// This structure is parsed from `config.toml`, and some of the fields are inferred from `git` or build-time parameters. /// /// Note that this structure is not decoded directly into, but rather it is /// filled out from the decoded forms of the structs below. For documentation diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 2b2b148f05e..53c8a1add78 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -347,6 +347,9 @@ pre { .source .content pre { padding: 20px; } +.rustdoc.source .example-wrap > pre.src-line-numbers { + padding: 20px 0 20px 4px; +} img { max-width: 100%; @@ -519,10 +522,6 @@ ul.block, .block li { display: none; } -.source .content pre.rust { - padding-left: 0; -} - .rustdoc .example-wrap { display: flex; position: relative; @@ -550,23 +549,21 @@ ul.block, .block li { -moz-user-select: none; -ms-user-select: none; user-select: none; + padding: 14px 8px; + color: var(--src-line-numbers-span-color); } -.example-line-numbers { - border: 1px solid; - padding: 13px 8px; - border-top-left-radius: 5px; - border-bottom-left-radius: 5px; - border-color: var(--example-line-numbers-border-color); +.rustdoc .example-wrap > pre.src-line-numbers { + padding: 14px 0; } - .src-line-numbers a, .src-line-numbers span { color: var(--src-line-numbers-span-color); + padding: 0 8px; } .src-line-numbers :target { background-color: transparent; border-right: none; - padding-right: 0; + padding: 0 8px; } .src-line-numbers .line-highlighted { background-color: var(--src-line-number-highlighted-background-color); @@ -1958,15 +1955,6 @@ in storage.js bottom: 0; } -.scraped-example .code-wrapper .src-line-numbers { - padding: 14px 0; -} - -.scraped-example .code-wrapper .src-line-numbers a, -.scraped-example .code-wrapper .src-line-numbers span { - padding: 0 14px; -} - .scraped-example .code-wrapper .example-wrap { width: 100%; overflow-y: hidden; diff --git a/src/librustdoc/html/static/css/themes/ayu.css b/src/librustdoc/html/static/css/themes/ayu.css index ce416f77afe..7377e2a1791 100644 --- a/src/librustdoc/html/static/css/themes/ayu.css +++ b/src/librustdoc/html/static/css/themes/ayu.css @@ -62,7 +62,6 @@ Original by Dempfi (https://github.com/dempfi/ayu) --code-highlight-question-mark-color: #ff9011; --code-highlight-comment-color: #788797; --code-highlight-doc-comment-color: #a1ac88; - --example-line-numbers-border-color: none; --src-line-numbers-span-color: #5c6773; --src-line-number-highlighted-background-color: rgba(255, 236, 164, 0.06); --test-arrow-color: #788797; @@ -132,7 +131,7 @@ pre, .rustdoc.source .example-wrap { .src-line-numbers .line-highlighted { color: #708090; - padding-right: 4px; + padding-right: 7px; border-right: 1px solid #ffb44c; } diff --git a/src/librustdoc/html/static/css/themes/dark.css b/src/librustdoc/html/static/css/themes/dark.css index 33d934ff3c3..2091f8dcca9 100644 --- a/src/librustdoc/html/static/css/themes/dark.css +++ b/src/librustdoc/html/static/css/themes/dark.css @@ -57,7 +57,6 @@ --code-highlight-question-mark-color: #ff9011; --code-highlight-comment-color: #8d8d8b; --code-highlight-doc-comment-color: #8ca375; - --example-line-numbers-border-color: #4a4949; --src-line-numbers-span-color: #3b91e2; --src-line-number-highlighted-background-color: #0a042f; --test-arrow-color: #dedede; diff --git a/src/librustdoc/html/static/css/themes/light.css b/src/librustdoc/html/static/css/themes/light.css index 30e91077d33..f582796d5dd 100644 --- a/src/librustdoc/html/static/css/themes/light.css +++ b/src/librustdoc/html/static/css/themes/light.css @@ -57,7 +57,6 @@ --code-highlight-question-mark-color: #ff9011; --code-highlight-comment-color: #8e908c; --code-highlight-doc-comment-color: #4d4d4c; - --example-line-numbers-border-color: #c7c7c7; --src-line-numbers-span-color: #c67e2d; --src-line-number-highlighted-background-color: #fdffd3; --test-arrow-color: #f5f5f5; diff --git a/src/test/codegen/comparison-operators-newtype.rs b/src/test/codegen/comparison-operators-newtype.rs new file mode 100644 index 00000000000..5cf6c3ac0a2 --- /dev/null +++ b/src/test/codegen/comparison-operators-newtype.rs @@ -0,0 +1,49 @@ +// The `derive(PartialOrd)` for a newtype doesn't override `lt`/`le`/`gt`/`ge`. +// This double-checks that the `Option<Ordering>` intermediate values used +// in the operators for such a type all optimize away. + +// compile-flags: -C opt-level=1 +// min-llvm-version: 15.0 + +#![crate_type = "lib"] + +use std::cmp::Ordering; + +#[derive(PartialOrd, PartialEq)] +pub struct Foo(u16); + +// CHECK-LABEL: @check_lt +// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +#[no_mangle] +pub fn check_lt(a: Foo, b: Foo) -> bool { + // CHECK: %[[R:.+]] = icmp ult i16 %[[A]], %[[B]] + // CHECK-NEXT: ret i1 %[[R]] + a < b +} + +// CHECK-LABEL: @check_le +// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +#[no_mangle] +pub fn check_le(a: Foo, b: Foo) -> bool { + // CHECK: %[[R:.+]] = icmp ule i16 %[[A]], %[[B]] + // CHECK-NEXT: ret i1 %[[R]] + a <= b +} + +// CHECK-LABEL: @check_gt +// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +#[no_mangle] +pub fn check_gt(a: Foo, b: Foo) -> bool { + // CHECK: %[[R:.+]] = icmp ugt i16 %[[A]], %[[B]] + // CHECK-NEXT: ret i1 %[[R]] + a > b +} + +// CHECK-LABEL: @check_ge +// CHECK-SAME: (i16 %[[A:.+]], i16 %[[B:.+]]) +#[no_mangle] +pub fn check_ge(a: Foo, b: Foo) -> bool { + // CHECK: %[[R:.+]] = icmp uge i16 %[[A]], %[[B]] + // CHECK-NEXT: ret i1 %[[R]] + a >= b +} diff --git a/src/test/rustdoc-gui/docblock-code-block-line-number.goml b/src/test/rustdoc-gui/docblock-code-block-line-number.goml index b094c483876..a3ed008719c 100644 --- a/src/test/rustdoc-gui/docblock-code-block-line-number.goml +++ b/src/test/rustdoc-gui/docblock-code-block-line-number.goml @@ -1,23 +1,53 @@ // Checks that the setting "line numbers" is working as expected. goto: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html" +// Otherwise, we can't check text color +show-text: true + // We check that without this setting, there is no line number displayed. assert-false: "pre.example-line-numbers" -// We now set the setting to show the line numbers on code examples. -local-storage: {"rustdoc-line-numbers": "true" } -// We reload to make the line numbers appear. -reload: - -// We wait for them to be added into the DOM by the JS... -wait-for: "pre.example-line-numbers" -// If the test didn't fail, it means that it was found! // Let's now check some CSS properties... -assert-css: ("pre.example-line-numbers", { - "margin": "0px", - "padding": "13px 8px", - "text-align": "right", +define-function: ( + "check-colors", + (theme, color), + [ + // We now set the setting to show the line numbers on code examples. + ("local-storage", { + "rustdoc-theme": |theme|, + "rustdoc-use-system-theme": "false", + "rustdoc-line-numbers": "true" + }), + // We reload to make the line numbers appear and change theme. + ("reload"), + // We wait for them to be added into the DOM by the JS... + ("wait-for", "pre.example-line-numbers"), + // If the test didn't fail, it means that it was found! + ("assert-css", ( + "pre.example-line-numbers", + { + "color": |color|, + "margin": "0px", + "padding": "14px 8px", + "text-align": "right", + }, + ALL, + )), + ], +) +call-function: ("check-colors", { + "theme": "ayu", + "color": "rgb(92, 103, 115)", }) +call-function: ("check-colors", { + "theme": "dark", + "color": "rgb(59, 145, 226)", +}) +call-function: ("check-colors", { + "theme": "light", + "color": "rgb(198, 126, 45)", +}) + // The first code block has two lines so let's check its `<pre>` elements lists both of them. assert-text: ("pre.example-line-numbers", "1\n2") diff --git a/src/test/rustdoc-gui/source-code-page.goml b/src/test/rustdoc-gui/source-code-page.goml index 25da74e5173..8a33e713191 100644 --- a/src/test/rustdoc-gui/source-code-page.goml +++ b/src/test/rustdoc-gui/source-code-page.goml @@ -89,9 +89,9 @@ assert-css: (".src-line-numbers", {"text-align": "right"}) // do anything (and certainly not add a `#NaN` to the URL!). goto: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html" // We use this assert-position to know where we will click. -assert-position: ("//*[@id='1']", {"x": 104, "y": 112}) +assert-position: ("//*[@id='1']", {"x": 88, "y": 112}) // We click on the left of the "1" anchor but still in the "src-line-number" `<pre>`. -click: (103, 103) +click: (87, 103) assert-document-property: ({"URL": "/lib.rs.html"}, ENDS_WITH) // Checking the source code sidebar. diff --git a/src/test/ui/suggestions/issue-105494.rs b/src/test/ui/suggestions/issue-105494.rs new file mode 100644 index 00000000000..8b409232c20 --- /dev/null +++ b/src/test/ui/suggestions/issue-105494.rs @@ -0,0 +1,22 @@ +fn test1() { + let _v: i32 = (1 as i32).to_string(); //~ ERROR mismatched types + + // won't suggestion + let _v: i32 = (1 as i128).to_string(); //~ ERROR mismatched types + + let _v: &str = "foo".to_string(); //~ ERROR mismatched types +} + +fn test2() { + let mut path: String = "/usr".to_string(); + let folder: String = "lib".to_string(); + + path = format!("{}/{}", path, folder).as_str(); //~ ERROR mismatched types + + println!("{}", &path); +} + +fn main() { + test1(); + test2(); +} diff --git a/src/test/ui/suggestions/issue-105494.stderr b/src/test/ui/suggestions/issue-105494.stderr new file mode 100644 index 00000000000..5aa3f2af738 --- /dev/null +++ b/src/test/ui/suggestions/issue-105494.stderr @@ -0,0 +1,54 @@ +error[E0308]: mismatched types + --> $DIR/issue-105494.rs:2:19 + | +LL | let _v: i32 = (1 as i32).to_string(); + | --- ^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String` + | | + | expected due to this + | +help: try removing the method call + | +LL - let _v: i32 = (1 as i32).to_string(); +LL + let _v: i32 = (1 as i32); + | + +error[E0308]: mismatched types + --> $DIR/issue-105494.rs:5:19 + | +LL | let _v: i32 = (1 as i128).to_string(); + | --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found struct `String` + | | + | expected due to this + +error[E0308]: mismatched types + --> $DIR/issue-105494.rs:7:20 + | +LL | let _v: &str = "foo".to_string(); + | ---- ^^^^^^^^^^^^^^^^^ expected `&str`, found struct `String` + | | + | expected due to this + | +help: try removing the method call + | +LL - let _v: &str = "foo".to_string(); +LL + let _v: &str = "foo"; + | + +error[E0308]: mismatched types + --> $DIR/issue-105494.rs:14:12 + | +LL | let mut path: String = "/usr".to_string(); + | ------ expected due to this type +... +LL | path = format!("{}/{}", path, folder).as_str(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `String`, found `&str` + | +help: try removing the method call + | +LL - path = format!("{}/{}", path, folder).as_str(); +LL + path = format!("{}/{}", path, folder); + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 95f6e047bf9..7a3c0d28fc3 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2303,6 +2303,8 @@ impl<'test> TestCx<'test> { } else { filecheck.args(&["--check-prefixes", &prefixes]); } + // Provide more context on failures. + filecheck.args(&["--dump-input-context", "100"]); self.compose_and_run(filecheck, "", None, None) } |
