Skip to content

Commit 4c3f8c7

Browse files
committed
Auto merge of #113256 - matthiaskrgr:rollup-poex8w2, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #113147 (Fix document examples of Vec::from_raw_parts and Vec::from_raw_parts_in) - #113202 (std docs: factorize literal in Barrier example) - #113228 (Migrate GUI colors test to original CSS color format) - #113231 (Fix `dropping_copy_types` lint from linting in match-arm with side-effects) - #113233 (Update chalk) - #113234 (Don't pass --test-args to `python -m unitest`) - #113244 (Make Rust Analyzer tests faster by compiling less code) - #113249 (Document tracking issue for rustdoc `show-type-layout`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 72b2101 + fde4102 commit 4c3f8c7

File tree

13 files changed

+107
-50
lines changed

13 files changed

+107
-50
lines changed

Cargo.lock

+10-10
Original file line numberDiff line numberDiff line change
@@ -414,21 +414,21 @@ dependencies = [
414414

415415
[[package]]
416416
name = "chalk-derive"
417-
version = "0.87.0"
417+
version = "0.92.0"
418418
source = "registry+https://github.com/rust-lang/crates.io-index"
419-
checksum = "d552b2fa341f5fc35c6b917b1d289d3c3a34d0b74e579390ea6192d6152a8cdb"
419+
checksum = "ff5053a8a42dbff5279a82423946fc56dc1253b76cf211b2b3c14b3aad4e1281"
420420
dependencies = [
421421
"proc-macro2",
422422
"quote",
423-
"syn 1.0.102",
424-
"synstructure 0.12.6",
423+
"syn 2.0.8",
424+
"synstructure 0.13.0",
425425
]
426426

427427
[[package]]
428428
name = "chalk-engine"
429-
version = "0.87.0"
429+
version = "0.92.0"
430430
source = "registry+https://github.com/rust-lang/crates.io-index"
431-
checksum = "7e54ac43048cb31c470d7b3e3acd409090ef4a5abddfe02455187aebc3d6879f"
431+
checksum = "b9d0e18f29b8b0f4dcf7d31fe00c884af67719699e381e8dcc9d9624b1621c60"
432432
dependencies = [
433433
"chalk-derive",
434434
"chalk-ir",
@@ -439,9 +439,9 @@ dependencies = [
439439

440440
[[package]]
441441
name = "chalk-ir"
442-
version = "0.87.0"
442+
version = "0.92.0"
443443
source = "registry+https://github.com/rust-lang/crates.io-index"
444-
checksum = "43aa55deff4e7fbdb09fa014543372f2c95a06835ac487b9ce57b5099b950838"
444+
checksum = "8a56de2146a8ed0fcd54f4bd50db852f1de4eac9e1efe568494f106c21b77d2a"
445445
dependencies = [
446446
"bitflags",
447447
"chalk-derive",
@@ -450,9 +450,9 @@ dependencies = [
450450

451451
[[package]]
452452
name = "chalk-solve"
453-
version = "0.87.0"
453+
version = "0.92.0"
454454
source = "registry+https://github.com/rust-lang/crates.io-index"
455-
checksum = "61213deefc36ba265ad01c4d997e18bcddf7922862a4594a47ca4575afb3dab4"
455+
checksum = "b392e02b4c81ec76d3748da839fc70a5539b83d27c9030668463d34d5110b860"
456456
dependencies = [
457457
"chalk-derive",
458458
"chalk-ir",

compiler/rustc_lint/src/drop_forget_useless.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ fn is_single_call_in_arm<'tcx>(
194194
arg: &'tcx Expr<'_>,
195195
drop_expr: &'tcx Expr<'_>,
196196
) -> bool {
197-
if matches!(arg.kind, ExprKind::Call(..) | ExprKind::MethodCall(..)) {
197+
if arg.can_have_side_effects() {
198198
let parent_node = cx.tcx.hir().find_parent(drop_expr.hir_id);
199199
if let Some(Node::Arm(Arm { body, .. })) = &parent_node {
200200
return body.hir_id == drop_expr.hir_id;

compiler/rustc_middle/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ edition = "2021"
77

88
[dependencies]
99
bitflags = "1.2.1"
10-
chalk-ir = "0.87.0"
10+
chalk-ir = "0.92.0"
1111
derive_more = "0.99.17"
1212
either = "1.5.0"
1313
gsgdt = "0.1.2"

compiler/rustc_traits/Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ rustc_hir = { path = "../rustc_hir" }
1111
rustc_ast = { path = "../rustc_ast" }
1212
rustc_span = { path = "../rustc_span" }
1313
rustc_target = { path = "../rustc_target" }
14-
chalk-ir = "0.87.0"
15-
chalk-engine = "0.87.0"
16-
chalk-solve = "0.87.0"
14+
chalk-ir = "0.92.0"
15+
chalk-engine = "0.92.0"
16+
chalk-solve = "0.92.0"
1717
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
1818
rustc_infer = { path = "../rustc_infer" }
1919
rustc_trait_selection = { path = "../rustc_trait_selection" }

compiler/rustc_traits/src/chalk/db.rs

+2
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
572572
DiscriminantKind => lang_items.discriminant_kind_trait(),
573573
DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
574574
Tuple => lang_items.tuple_trait(),
575+
Pointee => lang_items.pointee_trait(),
576+
FnPtr => lang_items.fn_ptr_trait(),
575577
};
576578
def_id.map(chalk_ir::TraitId)
577579
}

library/alloc/src/vec/mod.rs

+15-14
Original file line numberDiff line numberDiff line change
@@ -560,22 +560,20 @@ impl<T> Vec<T> {
560560
/// Using memory that was allocated elsewhere:
561561
///
562562
/// ```rust
563-
/// #![feature(allocator_api)]
564-
///
565-
/// use std::alloc::{AllocError, Allocator, Global, Layout};
563+
/// use std::alloc::{alloc, Layout};
566564
///
567565
/// fn main() {
568566
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
569567
///
570568
/// let vec = unsafe {
571-
/// let mem = match Global.allocate(layout) {
572-
/// Ok(mem) => mem.cast::<u32>().as_ptr(),
573-
/// Err(AllocError) => return,
574-
/// };
569+
/// let mem = alloc(layout).cast::<u32>();
570+
/// if mem.is_null() {
571+
/// return;
572+
/// }
575573
///
576574
/// mem.write(1_000_000);
577575
///
578-
/// Vec::from_raw_parts_in(mem, 1, 16, Global)
576+
/// Vec::from_raw_parts(mem, 1, 16)
579577
/// };
580578
///
581579
/// assert_eq!(vec, &[1_000_000]);
@@ -758,19 +756,22 @@ impl<T, A: Allocator> Vec<T, A> {
758756
/// Using memory that was allocated elsewhere:
759757
///
760758
/// ```rust
761-
/// use std::alloc::{alloc, Layout};
759+
/// #![feature(allocator_api)]
760+
///
761+
/// use std::alloc::{AllocError, Allocator, Global, Layout};
762762
///
763763
/// fn main() {
764764
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
765+
///
765766
/// let vec = unsafe {
766-
/// let mem = alloc(layout).cast::<u32>();
767-
/// if mem.is_null() {
768-
/// return;
769-
/// }
767+
/// let mem = match Global.allocate(layout) {
768+
/// Ok(mem) => mem.cast::<u32>().as_ptr(),
769+
/// Err(AllocError) => return,
770+
/// };
770771
///
771772
/// mem.write(1_000_000);
772773
///
773-
/// Vec::from_raw_parts(mem, 1, 16)
774+
/// Vec::from_raw_parts_in(mem, 1, 16, Global)
774775
/// };
775776
///
776777
/// assert_eq!(vec, &[1_000_000]);

library/std/src/sync/barrier.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ use crate::sync::{Condvar, Mutex};
1313
/// use std::sync::{Arc, Barrier};
1414
/// use std::thread;
1515
///
16-
/// let mut handles = Vec::with_capacity(10);
17-
/// let barrier = Arc::new(Barrier::new(10));
18-
/// for _ in 0..10 {
16+
/// let n = 10;
17+
/// let mut handles = Vec::with_capacity(n);
18+
/// let barrier = Arc::new(Barrier::new(n));
19+
/// for _ in 0..n {
1920
/// let c = Arc::clone(&barrier);
2021
/// // The same messages will be printed together.
2122
/// // You will NOT see any interleaving.
@@ -105,9 +106,10 @@ impl Barrier {
105106
/// use std::sync::{Arc, Barrier};
106107
/// use std::thread;
107108
///
108-
/// let mut handles = Vec::with_capacity(10);
109-
/// let barrier = Arc::new(Barrier::new(10));
110-
/// for _ in 0..10 {
109+
/// let n = 10;
110+
/// let mut handles = Vec::with_capacity(n);
111+
/// let barrier = Arc::new(Barrier::new(n));
112+
/// for _ in 0..n {
111113
/// let c = Arc::clone(&barrier);
112114
/// // The same messages will be printed together.
113115
/// // You will NOT see any interleaving.

src/bootstrap/bootstrap_test.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Bootstrap tests
22
3-
Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`."""
3+
Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstrap_test.py`."""
44

55
from __future__ import absolute_import, division, print_function
66
import os
@@ -12,6 +12,10 @@
1212

1313
from shutil import rmtree
1414

15+
# Allow running this from the top-level directory.
16+
bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
17+
# For the import below, have Python search in src/bootstrap first.
18+
sys.path.insert(0, bootstrap_dir)
1519
import bootstrap
1620
import configure
1721

@@ -131,8 +135,13 @@ def build_args(self, configure_args=[], args=[], env={}):
131135

132136
parsed = bootstrap.parse_args(args)
133137
build = serialize_and_parse(configure_args, parsed)
134-
build.build_dir = os.environ["BUILD_DIR"]
135-
build.build = os.environ["BUILD_PLATFORM"]
138+
# Make these optional so that `python -m unittest` works when run manually.
139+
build_dir = os.environ.get("BUILD_DIR")
140+
if build_dir is not None:
141+
build.build_dir = build_dir
142+
build_platform = os.environ.get("BUILD_PLATFORM")
143+
if build_platform is not None:
144+
build.build = build_platform
136145
return build.build_bootstrap_cmd(env), env
137146

138147
def test_cargoflags(self):

src/bootstrap/test.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ impl Step for RustAnalyzer {
379379
let host = self.host;
380380
let compiler = builder.compiler(stage, host);
381381

382-
builder.ensure(tool::RustAnalyzer { compiler, target: self.host }).expect("in-tree tool");
382+
// We don't need to build the whole Rust Analyzer for the proc-macro-srv test suite,
383+
// but we do need the standard library to be present.
384+
builder.ensure(compile::Std::new(compiler, host));
383385

384386
let workspace_path = "src/tools/rust-analyzer";
385387
// until the whole RA test suite runs on `i686`, we only run
@@ -2682,8 +2684,9 @@ impl Step for Bootstrap {
26822684
.args(["-m", "unittest", "bootstrap_test.py"])
26832685
.env("BUILD_DIR", &builder.out)
26842686
.env("BUILD_PLATFORM", &builder.build.build.triple)
2685-
.current_dir(builder.src.join("src/bootstrap/"))
2686-
.args(builder.config.test_args());
2687+
.current_dir(builder.src.join("src/bootstrap/"));
2688+
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
2689+
// Use `python -m unittest` manually if you want to pass arguments.
26872690
try_run(builder, &mut check_bootstrap).unwrap();
26882691

26892692
let host = builder.config.build;

src/doc/rustdoc/src/unstable-features.md

+2
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ the source.
310310

311311
### `--show-type-layout`: add a section to each type's docs describing its memory layout
312312

313+
* Tracking issue: [#113248](https://github.com/rust-lang/rust/issues/113248)
314+
313315
Using this flag looks like this:
314316

315317
```bash

tests/rustdoc-gui/search-filter.goml

+9-9
Original file line numberDiff line numberDiff line change
@@ -65,25 +65,25 @@ reload:
6565
set-timeout: 2000
6666
wait-for: "#crate-search"
6767
assert-css: ("#crate-search", {
68-
"border": "1px solid rgb(224, 224, 224)",
69-
"color": "rgb(0, 0, 0)",
70-
"background-color": "rgb(255, 255, 255)",
68+
"border": "1px solid #e0e0e0",
69+
"color": "black",
70+
"background-color": "white",
7171
})
7272

7373
// We now check the dark theme.
7474
click: "#settings-menu"
7575
wait-for: "#settings"
7676
click: "#theme-dark"
7777
wait-for-css: ("#crate-search", {
78-
"border": "1px solid rgb(224, 224, 224)",
79-
"color": "rgb(221, 221, 221)",
80-
"background-color": "rgb(53, 53, 53)",
78+
"border": "1px solid #e0e0e0",
79+
"color": "#ddd",
80+
"background-color": "#353535",
8181
})
8282

8383
// And finally we check the ayu theme.
8484
click: "#theme-ayu"
8585
wait-for-css: ("#crate-search", {
86-
"border": "1px solid rgb(92, 103, 115)",
87-
"color": "rgb(255, 255, 255)",
88-
"background-color": "rgb(15, 20, 25)",
86+
"border": "1px solid #5c6773",
87+
"color": "#fff",
88+
"background-color": "#0f1419",
8989
})

tests/ui/lint/dropping_copy_types.rs

+19
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,22 @@ fn issue9482(x: u8) {
7777
_ => (),
7878
}
7979
}
80+
81+
fn issue112653() {
82+
fn foo() -> Result<u8, ()> {
83+
println!("doing foo");
84+
Ok(0) // result is not always useful, the side-effect matters
85+
}
86+
fn bar() {
87+
println!("doing bar");
88+
}
89+
90+
fn stuff() -> Result<(), ()> {
91+
match 42 {
92+
0 => drop(foo()?), // drop is needed because we only care about side-effects
93+
1 => bar(),
94+
_ => (), // doing nothing (no side-effects needed here)
95+
}
96+
Ok(())
97+
}
98+
}

tests/ui/lint/dropping_references.rs

+19
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,22 @@ fn issue10122(x: u8) {
9797
_ => (),
9898
}
9999
}
100+
101+
fn issue112653() {
102+
fn foo() -> Result<&'static u8, ()> {
103+
println!("doing foo");
104+
Ok(&0) // result is not always useful, the side-effect matters
105+
}
106+
fn bar() {
107+
println!("doing bar");
108+
}
109+
110+
fn stuff() -> Result<(), ()> {
111+
match 42 {
112+
0 => drop(foo()?), // drop is needed because we only care about side-effects
113+
1 => bar(),
114+
_ => (), // doing nothing (no side-effects needed here)
115+
}
116+
Ok(())
117+
}
118+
}

0 commit comments

Comments
 (0)