mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
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
This commit is contained in:
commit
4c3f8c728b
20
Cargo.lock
20
Cargo.lock
@ -414,21 +414,21 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-derive"
|
name = "chalk-derive"
|
||||||
version = "0.87.0"
|
version = "0.92.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d552b2fa341f5fc35c6b917b1d289d3c3a34d0b74e579390ea6192d6152a8cdb"
|
checksum = "ff5053a8a42dbff5279a82423946fc56dc1253b76cf211b2b3c14b3aad4e1281"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 1.0.102",
|
"syn 2.0.8",
|
||||||
"synstructure 0.12.6",
|
"synstructure 0.13.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-engine"
|
name = "chalk-engine"
|
||||||
version = "0.87.0"
|
version = "0.92.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7e54ac43048cb31c470d7b3e3acd409090ef4a5abddfe02455187aebc3d6879f"
|
checksum = "b9d0e18f29b8b0f4dcf7d31fe00c884af67719699e381e8dcc9d9624b1621c60"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
@ -439,9 +439,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-ir"
|
name = "chalk-ir"
|
||||||
version = "0.87.0"
|
version = "0.92.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "43aa55deff4e7fbdb09fa014543372f2c95a06835ac487b9ce57b5099b950838"
|
checksum = "8a56de2146a8ed0fcd54f4bd50db852f1de4eac9e1efe568494f106c21b77d2a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
@ -450,9 +450,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "chalk-solve"
|
name = "chalk-solve"
|
||||||
version = "0.87.0"
|
version = "0.92.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "61213deefc36ba265ad01c4d997e18bcddf7922862a4594a47ca4575afb3dab4"
|
checksum = "b392e02b4c81ec76d3748da839fc70a5539b83d27c9030668463d34d5110b860"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chalk-derive",
|
"chalk-derive",
|
||||||
"chalk-ir",
|
"chalk-ir",
|
||||||
|
@ -194,7 +194,7 @@ fn is_single_call_in_arm<'tcx>(
|
|||||||
arg: &'tcx Expr<'_>,
|
arg: &'tcx Expr<'_>,
|
||||||
drop_expr: &'tcx Expr<'_>,
|
drop_expr: &'tcx Expr<'_>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
if matches!(arg.kind, ExprKind::Call(..) | ExprKind::MethodCall(..)) {
|
if arg.can_have_side_effects() {
|
||||||
let parent_node = cx.tcx.hir().find_parent(drop_expr.hir_id);
|
let parent_node = cx.tcx.hir().find_parent(drop_expr.hir_id);
|
||||||
if let Some(Node::Arm(Arm { body, .. })) = &parent_node {
|
if let Some(Node::Arm(Arm { body, .. })) = &parent_node {
|
||||||
return body.hir_id == drop_expr.hir_id;
|
return body.hir_id == drop_expr.hir_id;
|
||||||
|
@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bitflags = "1.2.1"
|
bitflags = "1.2.1"
|
||||||
chalk-ir = "0.87.0"
|
chalk-ir = "0.92.0"
|
||||||
derive_more = "0.99.17"
|
derive_more = "0.99.17"
|
||||||
either = "1.5.0"
|
either = "1.5.0"
|
||||||
gsgdt = "0.1.2"
|
gsgdt = "0.1.2"
|
||||||
|
@ -11,9 +11,9 @@ rustc_hir = { path = "../rustc_hir" }
|
|||||||
rustc_ast = { path = "../rustc_ast" }
|
rustc_ast = { path = "../rustc_ast" }
|
||||||
rustc_span = { path = "../rustc_span" }
|
rustc_span = { path = "../rustc_span" }
|
||||||
rustc_target = { path = "../rustc_target" }
|
rustc_target = { path = "../rustc_target" }
|
||||||
chalk-ir = "0.87.0"
|
chalk-ir = "0.92.0"
|
||||||
chalk-engine = "0.87.0"
|
chalk-engine = "0.92.0"
|
||||||
chalk-solve = "0.87.0"
|
chalk-solve = "0.92.0"
|
||||||
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
|
||||||
rustc_infer = { path = "../rustc_infer" }
|
rustc_infer = { path = "../rustc_infer" }
|
||||||
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
rustc_trait_selection = { path = "../rustc_trait_selection" }
|
||||||
|
@ -572,6 +572,8 @@ impl<'tcx> chalk_solve::RustIrDatabase<RustInterner<'tcx>> for RustIrDatabase<'t
|
|||||||
DiscriminantKind => lang_items.discriminant_kind_trait(),
|
DiscriminantKind => lang_items.discriminant_kind_trait(),
|
||||||
DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
|
DispatchFromDyn => lang_items.dispatch_from_dyn_trait(),
|
||||||
Tuple => lang_items.tuple_trait(),
|
Tuple => lang_items.tuple_trait(),
|
||||||
|
Pointee => lang_items.pointee_trait(),
|
||||||
|
FnPtr => lang_items.fn_ptr_trait(),
|
||||||
};
|
};
|
||||||
def_id.map(chalk_ir::TraitId)
|
def_id.map(chalk_ir::TraitId)
|
||||||
}
|
}
|
||||||
|
@ -560,22 +560,20 @@ impl<T> Vec<T> {
|
|||||||
/// Using memory that was allocated elsewhere:
|
/// Using memory that was allocated elsewhere:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// #![feature(allocator_api)]
|
/// use std::alloc::{alloc, Layout};
|
||||||
///
|
|
||||||
/// use std::alloc::{AllocError, Allocator, Global, Layout};
|
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
|
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
|
||||||
///
|
///
|
||||||
/// let vec = unsafe {
|
/// let vec = unsafe {
|
||||||
/// let mem = match Global.allocate(layout) {
|
/// let mem = alloc(layout).cast::<u32>();
|
||||||
/// Ok(mem) => mem.cast::<u32>().as_ptr(),
|
/// if mem.is_null() {
|
||||||
/// Err(AllocError) => return,
|
/// return;
|
||||||
/// };
|
/// }
|
||||||
///
|
///
|
||||||
/// mem.write(1_000_000);
|
/// mem.write(1_000_000);
|
||||||
///
|
///
|
||||||
/// Vec::from_raw_parts_in(mem, 1, 16, Global)
|
/// Vec::from_raw_parts(mem, 1, 16)
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// assert_eq!(vec, &[1_000_000]);
|
/// assert_eq!(vec, &[1_000_000]);
|
||||||
@ -758,19 +756,22 @@ impl<T, A: Allocator> Vec<T, A> {
|
|||||||
/// Using memory that was allocated elsewhere:
|
/// Using memory that was allocated elsewhere:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::alloc::{alloc, Layout};
|
/// #![feature(allocator_api)]
|
||||||
|
///
|
||||||
|
/// use std::alloc::{AllocError, Allocator, Global, Layout};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
|
/// let layout = Layout::array::<u32>(16).expect("overflow cannot happen");
|
||||||
|
///
|
||||||
/// let vec = unsafe {
|
/// let vec = unsafe {
|
||||||
/// let mem = alloc(layout).cast::<u32>();
|
/// let mem = match Global.allocate(layout) {
|
||||||
/// if mem.is_null() {
|
/// Ok(mem) => mem.cast::<u32>().as_ptr(),
|
||||||
/// return;
|
/// Err(AllocError) => return,
|
||||||
/// }
|
/// };
|
||||||
///
|
///
|
||||||
/// mem.write(1_000_000);
|
/// mem.write(1_000_000);
|
||||||
///
|
///
|
||||||
/// Vec::from_raw_parts(mem, 1, 16)
|
/// Vec::from_raw_parts_in(mem, 1, 16, Global)
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// assert_eq!(vec, &[1_000_000]);
|
/// assert_eq!(vec, &[1_000_000]);
|
||||||
|
@ -13,9 +13,10 @@ use crate::sync::{Condvar, Mutex};
|
|||||||
/// use std::sync::{Arc, Barrier};
|
/// use std::sync::{Arc, Barrier};
|
||||||
/// use std::thread;
|
/// use std::thread;
|
||||||
///
|
///
|
||||||
/// let mut handles = Vec::with_capacity(10);
|
/// let n = 10;
|
||||||
/// let barrier = Arc::new(Barrier::new(10));
|
/// let mut handles = Vec::with_capacity(n);
|
||||||
/// for _ in 0..10 {
|
/// let barrier = Arc::new(Barrier::new(n));
|
||||||
|
/// for _ in 0..n {
|
||||||
/// let c = Arc::clone(&barrier);
|
/// let c = Arc::clone(&barrier);
|
||||||
/// // The same messages will be printed together.
|
/// // The same messages will be printed together.
|
||||||
/// // You will NOT see any interleaving.
|
/// // You will NOT see any interleaving.
|
||||||
@ -105,9 +106,10 @@ impl Barrier {
|
|||||||
/// use std::sync::{Arc, Barrier};
|
/// use std::sync::{Arc, Barrier};
|
||||||
/// use std::thread;
|
/// use std::thread;
|
||||||
///
|
///
|
||||||
/// let mut handles = Vec::with_capacity(10);
|
/// let n = 10;
|
||||||
/// let barrier = Arc::new(Barrier::new(10));
|
/// let mut handles = Vec::with_capacity(n);
|
||||||
/// for _ in 0..10 {
|
/// let barrier = Arc::new(Barrier::new(n));
|
||||||
|
/// for _ in 0..n {
|
||||||
/// let c = Arc::clone(&barrier);
|
/// let c = Arc::clone(&barrier);
|
||||||
/// // The same messages will be printed together.
|
/// // The same messages will be printed together.
|
||||||
/// // You will NOT see any interleaving.
|
/// // You will NOT see any interleaving.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Bootstrap tests
|
"""Bootstrap tests
|
||||||
|
|
||||||
Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`."""
|
Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstrap_test.py`."""
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
import os
|
import os
|
||||||
@ -12,6 +12,10 @@ import sys
|
|||||||
|
|
||||||
from shutil import rmtree
|
from shutil import rmtree
|
||||||
|
|
||||||
|
# Allow running this from the top-level directory.
|
||||||
|
bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
# For the import below, have Python search in src/bootstrap first.
|
||||||
|
sys.path.insert(0, bootstrap_dir)
|
||||||
import bootstrap
|
import bootstrap
|
||||||
import configure
|
import configure
|
||||||
|
|
||||||
@ -131,8 +135,13 @@ class BuildBootstrap(unittest.TestCase):
|
|||||||
|
|
||||||
parsed = bootstrap.parse_args(args)
|
parsed = bootstrap.parse_args(args)
|
||||||
build = serialize_and_parse(configure_args, parsed)
|
build = serialize_and_parse(configure_args, parsed)
|
||||||
build.build_dir = os.environ["BUILD_DIR"]
|
# Make these optional so that `python -m unittest` works when run manually.
|
||||||
build.build = os.environ["BUILD_PLATFORM"]
|
build_dir = os.environ.get("BUILD_DIR")
|
||||||
|
if build_dir is not None:
|
||||||
|
build.build_dir = build_dir
|
||||||
|
build_platform = os.environ.get("BUILD_PLATFORM")
|
||||||
|
if build_platform is not None:
|
||||||
|
build.build = build_platform
|
||||||
return build.build_bootstrap_cmd(env), env
|
return build.build_bootstrap_cmd(env), env
|
||||||
|
|
||||||
def test_cargoflags(self):
|
def test_cargoflags(self):
|
||||||
|
@ -379,7 +379,9 @@ impl Step for RustAnalyzer {
|
|||||||
let host = self.host;
|
let host = self.host;
|
||||||
let compiler = builder.compiler(stage, host);
|
let compiler = builder.compiler(stage, host);
|
||||||
|
|
||||||
builder.ensure(tool::RustAnalyzer { compiler, target: self.host }).expect("in-tree tool");
|
// We don't need to build the whole Rust Analyzer for the proc-macro-srv test suite,
|
||||||
|
// but we do need the standard library to be present.
|
||||||
|
builder.ensure(compile::Std::new(compiler, host));
|
||||||
|
|
||||||
let workspace_path = "src/tools/rust-analyzer";
|
let workspace_path = "src/tools/rust-analyzer";
|
||||||
// until the whole RA test suite runs on `i686`, we only run
|
// until the whole RA test suite runs on `i686`, we only run
|
||||||
@ -2682,8 +2684,9 @@ impl Step for Bootstrap {
|
|||||||
.args(["-m", "unittest", "bootstrap_test.py"])
|
.args(["-m", "unittest", "bootstrap_test.py"])
|
||||||
.env("BUILD_DIR", &builder.out)
|
.env("BUILD_DIR", &builder.out)
|
||||||
.env("BUILD_PLATFORM", &builder.build.build.triple)
|
.env("BUILD_PLATFORM", &builder.build.build.triple)
|
||||||
.current_dir(builder.src.join("src/bootstrap/"))
|
.current_dir(builder.src.join("src/bootstrap/"));
|
||||||
.args(builder.config.test_args());
|
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
|
||||||
|
// Use `python -m unittest` manually if you want to pass arguments.
|
||||||
try_run(builder, &mut check_bootstrap).unwrap();
|
try_run(builder, &mut check_bootstrap).unwrap();
|
||||||
|
|
||||||
let host = builder.config.build;
|
let host = builder.config.build;
|
||||||
|
@ -310,6 +310,8 @@ the source.
|
|||||||
|
|
||||||
### `--show-type-layout`: add a section to each type's docs describing its memory layout
|
### `--show-type-layout`: add a section to each type's docs describing its memory layout
|
||||||
|
|
||||||
|
* Tracking issue: [#113248](https://github.com/rust-lang/rust/issues/113248)
|
||||||
|
|
||||||
Using this flag looks like this:
|
Using this flag looks like this:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
@ -65,9 +65,9 @@ reload:
|
|||||||
set-timeout: 2000
|
set-timeout: 2000
|
||||||
wait-for: "#crate-search"
|
wait-for: "#crate-search"
|
||||||
assert-css: ("#crate-search", {
|
assert-css: ("#crate-search", {
|
||||||
"border": "1px solid rgb(224, 224, 224)",
|
"border": "1px solid #e0e0e0",
|
||||||
"color": "rgb(0, 0, 0)",
|
"color": "black",
|
||||||
"background-color": "rgb(255, 255, 255)",
|
"background-color": "white",
|
||||||
})
|
})
|
||||||
|
|
||||||
// We now check the dark theme.
|
// We now check the dark theme.
|
||||||
@ -75,15 +75,15 @@ click: "#settings-menu"
|
|||||||
wait-for: "#settings"
|
wait-for: "#settings"
|
||||||
click: "#theme-dark"
|
click: "#theme-dark"
|
||||||
wait-for-css: ("#crate-search", {
|
wait-for-css: ("#crate-search", {
|
||||||
"border": "1px solid rgb(224, 224, 224)",
|
"border": "1px solid #e0e0e0",
|
||||||
"color": "rgb(221, 221, 221)",
|
"color": "#ddd",
|
||||||
"background-color": "rgb(53, 53, 53)",
|
"background-color": "#353535",
|
||||||
})
|
})
|
||||||
|
|
||||||
// And finally we check the ayu theme.
|
// And finally we check the ayu theme.
|
||||||
click: "#theme-ayu"
|
click: "#theme-ayu"
|
||||||
wait-for-css: ("#crate-search", {
|
wait-for-css: ("#crate-search", {
|
||||||
"border": "1px solid rgb(92, 103, 115)",
|
"border": "1px solid #5c6773",
|
||||||
"color": "rgb(255, 255, 255)",
|
"color": "#fff",
|
||||||
"background-color": "rgb(15, 20, 25)",
|
"background-color": "#0f1419",
|
||||||
})
|
})
|
||||||
|
@ -77,3 +77,22 @@ fn issue9482(x: u8) {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue112653() {
|
||||||
|
fn foo() -> Result<u8, ()> {
|
||||||
|
println!("doing foo");
|
||||||
|
Ok(0) // result is not always useful, the side-effect matters
|
||||||
|
}
|
||||||
|
fn bar() {
|
||||||
|
println!("doing bar");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stuff() -> Result<(), ()> {
|
||||||
|
match 42 {
|
||||||
|
0 => drop(foo()?), // drop is needed because we only care about side-effects
|
||||||
|
1 => bar(),
|
||||||
|
_ => (), // doing nothing (no side-effects needed here)
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -97,3 +97,22 @@ fn issue10122(x: u8) {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn issue112653() {
|
||||||
|
fn foo() -> Result<&'static u8, ()> {
|
||||||
|
println!("doing foo");
|
||||||
|
Ok(&0) // result is not always useful, the side-effect matters
|
||||||
|
}
|
||||||
|
fn bar() {
|
||||||
|
println!("doing bar");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stuff() -> Result<(), ()> {
|
||||||
|
match 42 {
|
||||||
|
0 => drop(foo()?), // drop is needed because we only care about side-effects
|
||||||
|
1 => bar(),
|
||||||
|
_ => (), // doing nothing (no side-effects needed here)
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user