Skip to content

Commit af204b1

Browse files
committed
Auto merge of #55171 - kennytm:rollup, r=kennytm
Rollup of 18 pull requests Successful merges: - #54646 (improve documentation on std::thread::sleep) - #54933 (Cleanup the rest of codegen_llvm) - #54964 (Run both lldb and gdb tests) - #55016 (Deduplicate some code and compile-time values around vtables) - #55031 (Improve verify_llvm_ir config option) - #55050 (doc std::fmt: the Python inspiration is already mentioned in precedin…) - #55077 (rustdoc: Use dyn keyword when rendering dynamic traits) - #55080 (Detect if access to localStorage is forbidden by the user's browser) - #55090 (regression test for move out of borrow via pattern) - #55102 (resolve: Do not skip extern prelude during speculative resolution) - #55104 (Add test for #34229) - #55111 ([Rustc Book] Explain --cfg's arguments) - #55122 (Cleanup mir/borrowck) - #55127 (Remove HybridBitSet::dummy) - #55128 (Fix LLVMRustInlineAsmVerify return type mismatch) - #55142 (miri: layout should not affect CTFE checks (outside of validation)) - #55151 (Cleanup nll) - #55161 ([librustdoc] Disable spellcheck for search field)
2 parents f7eb7fb + 1c09006 commit af204b1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+473
-280
lines changed

src/bootstrap/bin/rustc.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,6 @@ fn main() {
287287
cmd.arg("--cfg").arg("parallel_queries");
288288
}
289289

290-
if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() {
291-
cmd.arg("-Z").arg("verify-llvm-ir");
292-
}
293-
294290
if env::var_os("RUSTC_DENY_WARNINGS").is_some() && env::var_os("RUSTC_EXTERNAL_TOOL").is_none()
295291
{
296292
cmd.arg("-Dwarnings");

src/bootstrap/builder.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,6 @@ impl<'a> Builder<'a> {
10001000
cargo.env("RUSTC_BACKTRACE_ON_ICE", "1");
10011001
}
10021002

1003-
if self.config.rust_verify_llvm_ir {
1004-
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
1005-
}
1006-
10071003
cargo.env("RUSTC_VERBOSE", self.verbosity.to_string());
10081004

10091005
// in std, we want to avoid denying warnings for stage 0 as that makes cfg's painful.

src/bootstrap/compile.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ pub fn rustc_cargo_env(builder: &Builder, cargo: &mut Command) {
569569
if builder.config.rustc_parallel_queries {
570570
cargo.env("RUSTC_PARALLEL_QUERIES", "1");
571571
}
572+
if builder.config.rust_verify_llvm_ir {
573+
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
574+
}
572575
}
573576

574577
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/test.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -812,8 +812,7 @@ default_test!(Incremental {
812812

813813
default_test!(Debuginfo {
814814
path: "src/test/debuginfo",
815-
// What this runs varies depending on the native platform being apple
816-
mode: "debuginfo-XXX",
815+
mode: "debuginfo",
817816
suite: "debuginfo"
818817
});
819818

@@ -950,18 +949,11 @@ impl Step for Compiletest {
950949
return;
951950
}
952951

953-
if mode == "debuginfo-XXX" {
954-
return if builder.config.build.contains("apple") {
955-
builder.ensure(Compiletest {
956-
mode: "debuginfo-lldb",
957-
..self
958-
});
959-
} else {
960-
builder.ensure(Compiletest {
961-
mode: "debuginfo-gdb",
952+
if mode == "debuginfo" {
953+
return builder.ensure(Compiletest {
954+
mode: "debuginfo-both",
962955
..self
963956
});
964-
};
965957
}
966958

967959
builder.ensure(dist::DebuggerScripts {

src/ci/run.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
6161
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"
6262
elif [ "$DEPLOY_ALT" != "" ]; then
6363
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
64+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
6465
fi
6566
else
6667
# We almost always want debug assertions enabled, but sometimes this takes too
@@ -74,6 +75,8 @@ else
7475
if [ "$NO_LLVM_ASSERTIONS" = "" ]; then
7576
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-assertions"
7677
fi
78+
79+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.verify-llvm-ir"
7780
fi
7881

7982
if [ "$RUST_RELEASE_CHANNEL" = "nightly" ] || [ "$DIST_REQUIRE_ALL_TOOLS" = "" ]; then

src/doc/rustc/src/command-line-arguments.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ This flag will print out help information for `rustc`.
1010

1111
This flag can turn on or off various `#[cfg]` settings.
1212

13+
The value can either be a single identifier or two identifiers separated by `=`.
14+
15+
For examples, `--cfg 'verbose'` or `--cfg 'feature="serde"'`. These correspond
16+
to `#[cfg(verbose)]` and `#[cfg(feature = "serde")]` respectively.
17+
1318
## `-L`: add a directory to the library search path
1419

1520
When looking for external crates, a directory passed to this flag will be searched.

src/liballoc/fmt.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@
335335
//!
336336
//! Each argument being formatted can be transformed by a number of formatting
337337
//! parameters (corresponding to `format_spec` in the syntax above). These
338-
//! parameters affect the string representation of what's being formatted. This
339-
//! syntax draws heavily from Python's, so it may seem a bit familiar.
338+
//! parameters affect the string representation of what's being formatted.
340339
//!
341340
//! ## Fill/Alignment
342341
//!

src/librustc/build.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,15 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::env;
12+
1113
fn main() {
1214
println!("cargo:rerun-if-changed=build.rs");
1315
println!("cargo:rerun-if-env-changed=CFG_LIBDIR_RELATIVE");
1416
println!("cargo:rerun-if-env-changed=CFG_COMPILER_HOST_TRIPLE");
17+
println!("cargo:rerun-if-env-changed=RUSTC_VERIFY_LLVM_IR");
18+
19+
if env::var_os("RUSTC_VERIFY_LLVM_IR").is_some() {
20+
println!("cargo:rustc-cfg=always_verify_llvm_ir");
21+
}
1522
}

src/librustc/session/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ impl Session {
525525
}
526526
pub fn verify_llvm_ir(&self) -> bool {
527527
self.opts.debugging_opts.verify_llvm_ir
528+
|| cfg!(always_verify_llvm_ir)
528529
}
529530
pub fn borrowck_stats(&self) -> bool {
530531
self.opts.debugging_opts.borrowck_stats

src/librustc/ty/query/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,16 @@ define_queries! { <'tcx>
369369
-> Lrc<specialization_graph::Graph>,
370370
[] fn is_object_safe: ObjectSafety(DefId) -> bool,
371371

372-
// Get the ParameterEnvironment for a given item; this environment
373-
// will be in "user-facing" mode, meaning that it is suitabe for
374-
// type-checking etc, and it does not normalize specializable
375-
// associated types. This is almost always what you want,
376-
// unless you are doing MIR optimizations, in which case you
377-
// might want to use `reveal_all()` method to change modes.
372+
/// Get the ParameterEnvironment for a given item; this environment
373+
/// will be in "user-facing" mode, meaning that it is suitabe for
374+
/// type-checking etc, and it does not normalize specializable
375+
/// associated types. This is almost always what you want,
376+
/// unless you are doing MIR optimizations, in which case you
377+
/// might want to use `reveal_all()` method to change modes.
378378
[] fn param_env: ParamEnv(DefId) -> ty::ParamEnv<'tcx>,
379379

380-
// Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
381-
// `ty.is_copy()`, etc, since that will prune the environment where possible.
380+
/// Trait selection queries. These are best used by invoking `ty.moves_by_default()`,
381+
/// `ty.is_copy()`, etc, since that will prune the environment where possible.
382382
[] fn is_copy_raw: is_copy_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
383383
[] fn is_sized_raw: is_sized_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,
384384
[] fn is_freeze_raw: is_freeze_dep_node(ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool,

src/librustc_codegen_llvm/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ impl Builder<'a, 'll, 'tcx> {
756756
// Ask LLVM to verify that the constraints are well-formed.
757757
let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons);
758758
debug!("Constraint verification result: {:?}", constraints_ok);
759-
if constraints_ok == llvm::True {
759+
if constraints_ok {
760760
let v = llvm::LLVMRustInlineAsm(
761761
fty, asm, cons, volatile, alignstack, dia);
762762
Some(self.call(v, inputs, None))

src/librustc_codegen_llvm/debuginfo/create_scope_map.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub struct MirDebugScope<'ll> {
3737

3838
impl MirDebugScope<'ll> {
3939
pub fn is_valid(&self) -> bool {
40-
!self.scope_metadata.is_none()
40+
self.scope_metadata.is_some()
4141
}
4242
}
4343

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ impl TypeMap<'ll, 'tcx> {
163163
fn get_unique_type_id_of_type<'a>(&mut self, cx: &CodegenCx<'a, 'tcx>,
164164
type_: Ty<'tcx>) -> UniqueTypeId {
165165
// Let's see if we already have something in the cache
166-
match self.type_to_unique_id.get(&type_).cloned() {
167-
Some(unique_type_id) => return unique_type_id,
168-
None => { /* generate one */}
169-
};
166+
if let Some(unique_type_id) = self.type_to_unique_id.get(&type_).cloned() {
167+
return unique_type_id;
168+
}
169+
// if not, generate one
170170

171171
// The hasher we are using to generate the UniqueTypeId. We want
172172
// something that provides more than the 64 bits of the DefaultHasher.
@@ -286,11 +286,11 @@ impl RecursiveTypeDescription<'ll, 'tcx> {
286286
// unique id can be found in the type map
287287
macro_rules! return_if_metadata_created_in_meantime {
288288
($cx: expr, $unique_type_id: expr) => (
289-
match debug_context($cx).type_map
289+
if let Some(metadata) = debug_context($cx).type_map
290290
.borrow()
291-
.find_metadata_for_unique_id($unique_type_id) {
292-
Some(metadata) => return MetadataCreationResult::new(metadata, true),
293-
None => { /* proceed normally */ }
291+
.find_metadata_for_unique_id($unique_type_id)
292+
{
293+
return MetadataCreationResult::new(metadata, true);
294294
}
295295
)
296296
}
@@ -352,15 +352,15 @@ fn vec_slice_metadata(
352352

353353
let member_descriptions = vec![
354354
MemberDescription {
355-
name: "data_ptr".to_string(),
355+
name: "data_ptr".to_owned(),
356356
type_metadata: data_ptr_metadata,
357357
offset: Size::ZERO,
358358
size: pointer_size,
359359
align: pointer_align,
360360
flags: DIFlags::FlagZero,
361361
},
362362
MemberDescription {
363-
name: "length".to_string(),
363+
name: "length".to_owned(),
364364
type_metadata: type_metadata(cx, cx.tcx.types.usize, span),
365365
offset: pointer_size,
366366
size: usize_size,
@@ -458,7 +458,7 @@ fn trait_pointer_metadata(
458458
let vtable_field = layout.field(cx, 1);
459459
let member_descriptions = vec![
460460
MemberDescription {
461-
name: "pointer".to_string(),
461+
name: "pointer".to_owned(),
462462
type_metadata: type_metadata(cx,
463463
cx.tcx.mk_mut_ptr(cx.tcx.types.u8),
464464
syntax_pos::DUMMY_SP),
@@ -468,7 +468,7 @@ fn trait_pointer_metadata(
468468
flags: DIFlags::FlagArtificial,
469469
},
470470
MemberDescription {
471-
name: "vtable".to_string(),
471+
name: "vtable".to_owned(),
472472
type_metadata: type_metadata(cx, vtable_field.ty, syntax_pos::DUMMY_SP),
473473
offset: layout.fields.offset(1),
474474
size: vtable_field.size,
@@ -543,12 +543,12 @@ pub fn type_metadata(
543543
_ => {
544544
let pointee_metadata = type_metadata(cx, ty, usage_site_span);
545545

546-
match debug_context(cx).type_map
546+
if let Some(metadata) = debug_context(cx).type_map
547547
.borrow()
548-
.find_metadata_for_unique_id(unique_type_id) {
549-
Some(metadata) => return Err(metadata),
550-
None => { /* proceed normally */ }
551-
};
548+
.find_metadata_for_unique_id(unique_type_id)
549+
{
550+
return Err(metadata);
551+
}
552552

553553
Ok(MetadataCreationResult::new(pointer_type_metadata(cx, t, pointee_metadata),
554554
false))
@@ -603,12 +603,12 @@ pub fn type_metadata(
603603
unique_type_id,
604604
t.fn_sig(cx.tcx),
605605
usage_site_span).metadata;
606-
match debug_context(cx).type_map
606+
if let Some(metadata) = debug_context(cx).type_map
607607
.borrow()
608-
.find_metadata_for_unique_id(unique_type_id) {
609-
Some(metadata) => return metadata,
610-
None => { /* proceed normally */ }
611-
};
608+
.find_metadata_for_unique_id(unique_type_id)
609+
{
610+
return metadata;
611+
}
612612

613613
// This is actually a function pointer, so wrap it in pointer DI
614614
MetadataCreationResult::new(pointer_type_metadata(cx, t, fn_metadata), false)
@@ -1357,7 +1357,7 @@ fn describe_enum_variant(
13571357
// We have the layout of an enum variant, we need the layout of the outer enum
13581358
let enum_layout = cx.layout_of(layout.ty);
13591359
(Some(enum_layout.fields.offset(0)),
1360-
Some(("RUST$ENUM$DISR".to_string(), enum_layout.field(cx, 0).ty)))
1360+
Some(("RUST$ENUM$DISR".to_owned(), enum_layout.field(cx, 0).ty)))
13611361
}
13621362
_ => (None, None),
13631363
};
@@ -1471,9 +1471,8 @@ fn prepare_enum_metadata(
14711471
}
14721472
};
14731473

1474-
match (&layout.abi, discriminant_type_metadata) {
1475-
(&layout::Abi::Scalar(_), Some(discr)) => return FinalMetadata(discr),
1476-
_ => {}
1474+
if let (&layout::Abi::Scalar(_), Some(discr)) = (&layout.abi, discriminant_type_metadata) {
1475+
return FinalMetadata(discr);
14771476
}
14781477

14791478
let (enum_type_size, enum_type_align) = layout.size_and_align();
@@ -1546,7 +1545,7 @@ fn composite_type_metadata(
15461545
composite_type_metadata,
15471546
member_descriptions);
15481547

1549-
return composite_type_metadata;
1548+
composite_type_metadata
15501549
}
15511550

15521551
fn set_members_of_composite_type(cx: &CodegenCx<'ll, '_>,
@@ -1634,7 +1633,7 @@ fn create_struct_stub(
16341633
unique_type_id.as_ptr())
16351634
};
16361635

1637-
return metadata_stub;
1636+
metadata_stub
16381637
}
16391638

16401639
fn create_union_stub(
@@ -1670,7 +1669,7 @@ fn create_union_stub(
16701669
unique_type_id.as_ptr())
16711670
};
16721671

1673-
return metadata_stub;
1672+
metadata_stub
16741673
}
16751674

16761675
/// Creates debug information for the given global variable.

src/librustc_codegen_llvm/debuginfo/mod.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -271,16 +271,14 @@ pub fn create_function_debug_context(
271271
let mut flags = DIFlags::FlagPrototyped;
272272

273273
let local_id = cx.tcx.hir.as_local_node_id(def_id);
274-
match *cx.sess().entry_fn.borrow() {
275-
Some((id, _, _)) => {
274+
if let Some((id, _, _)) = *cx.sess().entry_fn.borrow() {
276275
if local_id == Some(id) {
277-
flags = flags | DIFlags::FlagMainSubprogram;
276+
flags |= DIFlags::FlagMainSubprogram;
278277
}
279278
}
280-
None => {}
281-
};
279+
282280
if cx.layout_of(sig.output()).abi.is_uninhabited() {
283-
flags = flags | DIFlags::FlagNoReturn;
281+
flags |= DIFlags::FlagNoReturn;
284282
}
285283

286284
let fn_metadata = unsafe {
@@ -371,7 +369,7 @@ pub fn create_function_debug_context(
371369
}
372370
}
373371

374-
return create_DIArray(DIB(cx), &signature[..]);
372+
create_DIArray(DIB(cx), &signature[..])
375373
}
376374

377375
fn get_template_parameters(
@@ -428,7 +426,7 @@ pub fn create_function_debug_context(
428426
vec![]
429427
};
430428

431-
return create_DIArray(DIB(cx), &template_params[..]);
429+
create_DIArray(DIB(cx), &template_params[..])
432430
}
433431

434432
fn get_parameter_names(cx: &CodegenCx,

src/librustc_codegen_llvm/debuginfo/source_loc.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ pub fn set_source_location(
5656
/// switches source location emitting on and must therefore be called before the
5757
/// first real statement/expression of the function is codegened.
5858
pub fn start_emitting_source_locations(dbg_context: &FunctionDebugContext<'ll>) {
59-
match *dbg_context {
60-
FunctionDebugContext::RegularContext(ref data) => {
61-
data.source_locations_enabled.set(true)
62-
},
63-
_ => { /* safe to ignore */ }
59+
if let FunctionDebugContext::RegularContext(ref data) = *dbg_context {
60+
data.source_locations_enabled.set(true);
6461
}
6562
}
6663

src/librustc_codegen_llvm/debuginfo/type_names.rs

Whitespace-only changes.

src/librustc_codegen_llvm/llvm/archive_ro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ArchiveRO {
4040
return unsafe {
4141
let s = path2cstr(dst);
4242
let ar = super::LLVMRustOpenArchive(s.as_ptr()).ok_or_else(|| {
43-
super::last_error().unwrap_or("failed to open archive".to_string())
43+
super::last_error().unwrap_or("failed to open archive".to_owned())
4444
})?;
4545
Ok(ArchiveRO { raw: ar })
4646
};

src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1213,7 +1213,7 @@ extern "C" {
12131213
-> &Value;
12141214
pub fn LLVMRustInlineAsmVerify(Ty: &Type,
12151215
Constraints: *const c_char)
1216-
-> Bool;
1216+
-> bool;
12171217

12181218
pub fn LLVMRustDebugMetadataVersion() -> u32;
12191219
pub fn LLVMRustVersionMajor() -> u32;

0 commit comments

Comments
 (0)