Skip to content

Commit 25a42b2

Browse files
committed
Auto merge of #55746 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests Successful merges: - #55377 (Slight copy-editing for `std::cell::Cell` docs) - #55441 (Remove unused re import in gdb_rust_pretty_printing) - #55453 (Choose predicates without inference variables over those with them) - #55495 (Don't print opt fuel messages to stdout because it breaks Rustbuild) - #55501 (Make `process_obligations`' computation of `completed` optional.) - #55510 (Fix feature gate only being checked on first repr attr.) - #55609 (Run name-anon-globals after LTO passes as well) - #55645 (do not print wrapping ranges like normal ranges in validity diagnostics) - #55688 (Standardised names and location of ui issue tests) - #55692 (-C remark: fix incorrect warning about requiring "--debuginfo" instead of "-C debuginfo=n") - #55702 (Add `aarch64-pc-windows-msvc` to deployed targets) - #55728 (Update lldb) - #55730 (Use trait impl method span when type param mismatch is due to impl Trait) - #55734 (refactor: use shorthand fields)
2 parents 8315b11 + 4e86576 commit 25a42b2

File tree

169 files changed

+505
-268
lines changed

Some content is hidden

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

169 files changed

+505
-268
lines changed

src/etc/gdb_rust_pretty_printing.py

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# except according to those terms.
1010

1111
import gdb
12-
import re
1312
import sys
1413
import debugger_pretty_printers_common as rustpp
1514

src/liballoc/string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl String {
502502
#[stable(feature = "rust1", since = "1.0.0")]
503503
pub fn from_utf8(vec: Vec<u8>) -> Result<String, FromUtf8Error> {
504504
match str::from_utf8(&vec) {
505-
Ok(..) => Ok(String { vec: vec }),
505+
Ok(..) => Ok(String { vec }),
506506
Err(e) => {
507507
Err(FromUtf8Error {
508508
bytes: vec,

src/libcore/cell.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ use ptr;
207207
///
208208
/// # Examples
209209
///
210-
/// Here you can see how using `Cell<T>` allows to use mutable field inside
211-
/// immutable struct (which is also called 'interior mutability').
210+
/// In this example, you can see that `Cell<T>` enables mutation inside an
211+
/// immutable struct. In other words, it enables "interior mutability".
212212
///
213213
/// ```
214214
/// use std::cell::Cell;
@@ -225,10 +225,11 @@ use ptr;
225225
///
226226
/// let new_value = 100;
227227
///
228-
/// // ERROR, because my_struct is immutable
228+
/// // ERROR: `my_struct` is immutable
229229
/// // my_struct.regular_field = new_value;
230230
///
231-
/// // WORKS, although `my_struct` is immutable, field `special_field` is mutable because it is Cell
231+
/// // WORKS: although `my_struct` is immutable, `special_field` is a `Cell`,
232+
/// // which can always be mutated
232233
/// my_struct.special_field.set(new_value);
233234
/// assert_eq!(my_struct.special_field.get(), new_value);
234235
/// ```

src/libpanic_unwind/dwarf/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Unaligned<T>(T);
2929

3030
impl DwarfReader {
3131
pub fn new(ptr: *const u8) -> DwarfReader {
32-
DwarfReader { ptr: ptr }
32+
DwarfReader { ptr }
3333
}
3434

3535
// DWARF streams are packed, so e.g. a u32 would not necessarily be aligned

src/libpanic_unwind/seh64_gnu.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct PanicData {
4141
}
4242

4343
pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
44-
let panic_ctx = Box::new(PanicData { data: data });
44+
let panic_ctx = Box::new(PanicData { data });
4545
let params = [Box::into_raw(panic_ctx) as c::ULONG_PTR];
4646
c::RaiseException(RUST_PANIC,
4747
c::EXCEPTION_NONCONTINUABLE,

src/librustc/infer/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub struct OpportunisticTypeResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
2626

2727
impl<'a, 'gcx, 'tcx> OpportunisticTypeResolver<'a, 'gcx, 'tcx> {
2828
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
29-
OpportunisticTypeResolver { infcx: infcx }
29+
OpportunisticTypeResolver { infcx }
3030
}
3131
}
3232

@@ -54,7 +54,7 @@ pub struct OpportunisticTypeAndRegionResolver<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
5454

5555
impl<'a, 'gcx, 'tcx> OpportunisticTypeAndRegionResolver<'a, 'gcx, 'tcx> {
5656
pub fn new(infcx: &'a InferCtxt<'a, 'gcx, 'tcx>) -> Self {
57-
OpportunisticTypeAndRegionResolver { infcx: infcx }
57+
OpportunisticTypeAndRegionResolver { infcx }
5858
}
5959
}
6060

src/librustc/infer/type_variable.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl<'tcx> TypeVariableTable<'tcx> {
169169
// Hack: we only need this so that `types_escaping_snapshot`
170170
// can see what has been unified; see the Delegate impl for
171171
// more details.
172-
self.values.record(Instantiate { vid: vid });
172+
self.values.record(Instantiate { vid });
173173
}
174174

175175
/// Creates a new type variable.

src/librustc/infer/unify_key.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl UnifyValue for RegionVidKey {
4343
value2.min_vid
4444
};
4545

46-
Ok(RegionVidKey { min_vid: min_vid })
46+
Ok(RegionVidKey { min_vid })
4747
}
4848
}
4949

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ impl<'a, 'tcx> Index<'tcx> {
469469
/// Cross-references the feature names of unstable APIs with enabled
470470
/// features and possibly prints errors.
471471
pub fn check_unstable_api_usage<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
472-
let mut checker = Checker { tcx: tcx };
472+
let mut checker = Checker { tcx };
473473
tcx.hir.krate().visit_all_item_likes(&mut checker.as_deep_visitor());
474474
}
475475

src/librustc/mir/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2986,7 +2986,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
29862986
use mir::TerminatorKind::*;
29872987

29882988
let kind = match self.kind {
2989-
Goto { target } => Goto { target: target },
2989+
Goto { target } => Goto { target },
29902990
SwitchInt {
29912991
ref discr,
29922992
switch_ty,

src/librustc/mir/tcx.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub enum PlaceTy<'tcx> {
3232

3333
impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
3434
pub fn from_ty(ty: Ty<'tcx>) -> PlaceTy<'tcx> {
35-
PlaceTy::Ty { ty: ty }
35+
PlaceTy::Ty { ty }
3636
}
3737

3838
pub fn to_ty(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Ty<'tcx> {

src/librustc/session/config.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -2202,8 +2202,7 @@ pub fn build_session_options_and_crate_config(
22022202
if !cg.remark.is_empty() && debuginfo == DebugInfo::None {
22032203
early_warn(
22042204
error_format,
2205-
"-C remark will not show source locations without \
2206-
--debuginfo",
2205+
"-C remark requires \"-C debuginfo=n\" to show source locations",
22072206
);
22082207
}
22092208

src/librustc/session/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ impl Session {
868868
let fuel = self.optimization_fuel_limit.get();
869869
ret = fuel != 0;
870870
if fuel == 0 && !self.out_of_fuel.get() {
871-
println!("optimization-fuel-exhausted: {}", msg());
871+
eprintln!("optimization-fuel-exhausted: {}", msg());
872872
self.out_of_fuel.set(true);
873873
} else if fuel > 0 {
874874
self.optimization_fuel_limit.set(fuel - 1);

src/librustc/traits/auto_trait.rs

+33-9
Original file line numberDiff line numberDiff line change
@@ -447,27 +447,51 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
447447
ty::RegionKind::ReLateBound(_, _),
448448
) => {}
449449

450-
(ty::RegionKind::ReLateBound(_, _), _) => {
450+
(ty::RegionKind::ReLateBound(_, _), _) |
451+
(_, ty::RegionKind::ReVar(_)) => {
452+
// One of these is true:
451453
// The new predicate has a HRTB in a spot where the old
452454
// predicate does not (if they both had a HRTB, the previous
453-
// match arm would have executed).
455+
// match arm would have executed). A HRBT is a 'stricter'
456+
// bound than anything else, so we want to keep the newer
457+
// predicate (with the HRBT) in place of the old predicate.
454458
//
455-
// The means we want to remove the older predicate from
456-
// user_computed_preds, since having both it and the new
459+
// OR
460+
//
461+
// The old predicate has a region variable where the new
462+
// predicate has some other kind of region. An region
463+
// variable isn't something we can actually display to a user,
464+
// so we choose ther new predicate (which doesn't have a region
465+
// varaible).
466+
//
467+
// In both cases, we want to remove the old predicate,
468+
// from user_computed_preds, and replace it with the new
469+
// one. Having both the old and the new
457470
// predicate in a ParamEnv would confuse SelectionContext
471+
//
458472
// We're currently in the predicate passed to 'retain',
459473
// so we return 'false' to remove the old predicate from
460474
// user_computed_preds
461475
return false;
462476
}
463-
(_, ty::RegionKind::ReLateBound(_, _)) => {
464-
// This is the opposite situation as the previous arm - the
465-
// old predicate has a HRTB lifetime in a place where the
466-
// new predicate does not. We want to leave the old
477+
(_, ty::RegionKind::ReLateBound(_, _)) |
478+
(ty::RegionKind::ReVar(_), _) => {
479+
// This is the opposite situation as the previous arm.
480+
// One of these is true:
481+
//
482+
// The old predicate has a HRTB lifetime in a place where the
483+
// new predicate does not.
484+
//
485+
// OR
486+
//
487+
// The new predicate has a region variable where the old
488+
// predicate has some other type of region.
489+
//
490+
// We want to leave the old
467491
// predicate in user_computed_preds, and skip adding
468492
// new_pred to user_computed_params.
469493
should_add_new = false
470-
}
494+
},
471495
_ => {}
472496
}
473497
}

src/librustc/traits/fulfill.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ use infer::InferCtxt;
1212
use mir::interpret::{GlobalId, ErrorHandled};
1313
use ty::{self, Ty, TypeFoldable, ToPolyTraitRef, ToPredicate};
1414
use ty::error::ExpectedFound;
15-
use rustc_data_structures::obligation_forest::{Error, ForestObligation, ObligationForest};
16-
use rustc_data_structures::obligation_forest::{ObligationProcessor, ProcessResult};
15+
use rustc_data_structures::obligation_forest::{DoCompleted, Error, ForestObligation};
16+
use rustc_data_structures::obligation_forest::{ObligationForest, ObligationProcessor};
17+
use rustc_data_structures::obligation_forest::{ProcessResult};
1718
use std::marker::PhantomData;
1819
use hir::def_id::DefId;
1920

@@ -98,7 +99,7 @@ impl<'a, 'gcx, 'tcx> FulfillmentContext<'tcx> {
9899
let outcome = self.predicates.process_obligations(&mut FulfillProcessor {
99100
selcx,
100101
register_region_obligations: self.register_region_obligations
101-
});
102+
}, DoCompleted::No);
102103
debug!("select: outcome={:#?}", outcome);
103104

104105
// FIXME: if we kept the original cache key, we could mark projection

src/librustc/traits/project.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ fn project_and_unify_type<'cx, 'gcx, 'tcx>(
266266
},
267267
Err(err) => {
268268
debug!("project_and_unify_type: equating types encountered error {:?}", err);
269-
Err(MismatchedProjectionTypes { err: err })
269+
Err(MismatchedProjectionTypes { err })
270270
}
271271
}
272272
}

src/librustc/traits/select.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3526,7 +3526,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
35263526
_ => bug!(),
35273527
};
35283528

3529-
Ok(VtableBuiltinData { nested: nested })
3529+
Ok(VtableBuiltinData { nested })
35303530
}
35313531

35323532
///////////////////////////////////////////////////////////////////////////

src/librustc/ty/_match.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Match<'a, 'gcx: 'a+'tcx, 'tcx: 'a> {
3434

3535
impl<'a, 'gcx, 'tcx> Match<'a, 'gcx, 'tcx> {
3636
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>) -> Match<'a, 'gcx, 'tcx> {
37-
Match { tcx: tcx }
37+
Match { tcx }
3838
}
3939
}
4040

src/librustc/ty/fold.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub trait TypeFoldable<'tcx>: fmt::Debug + Clone {
8282
}
8383

8484
fn has_type_flags(&self, flags: TypeFlags) -> bool {
85-
self.visit_with(&mut HasTypeFlagsVisitor { flags: flags })
85+
self.visit_with(&mut HasTypeFlagsVisitor { flags })
8686
}
8787
fn has_projections(&self) -> bool {
8888
self.has_type_flags(TypeFlags::HAS_PROJECTION)

src/librustc_codegen_llvm/back/lto.rs

+7
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,13 @@ fn run_pass_manager(cgcx: &CodegenContext,
605605
}
606606
});
607607

608+
// We always generate bitcode through ThinLTOBuffers,
609+
// which do not support anonymous globals
610+
if config.bitcode_needed() {
611+
let pass = llvm::LLVMRustFindAndCreatePass("name-anon-globals\0".as_ptr() as *const _);
612+
llvm::LLVMRustAddPass(pm, pass.unwrap());
613+
}
614+
608615
if config.verify_llvm_ir {
609616
let pass = llvm::LLVMRustFindAndCreatePass("verify\0".as_ptr() as *const _);
610617
llvm::LLVMRustAddPass(pm, pass.unwrap());

src/librustc_codegen_llvm/back/write.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,11 @@ impl ModuleConfig {
337337
self.merge_functions = sess.opts.optimize == config::OptLevel::Default ||
338338
sess.opts.optimize == config::OptLevel::Aggressive;
339339
}
340+
341+
pub fn bitcode_needed(&self) -> bool {
342+
self.emit_bc || self.obj_is_bitcode
343+
|| self.emit_bc_compressed || self.embed_bitcode
344+
}
340345
}
341346

342347
/// Assembler name and command used by codegen when no_integrated_as is enabled
@@ -564,8 +569,7 @@ unsafe fn optimize(cgcx: &CodegenContext,
564569
// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
565570
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
566571
// we'll get errors in LLVM.
567-
let using_thin_buffers = config.emit_bc || config.obj_is_bitcode
568-
|| config.emit_bc_compressed || config.embed_bitcode;
572+
let using_thin_buffers = config.bitcode_needed();
569573
let mut have_name_anon_globals_pass = false;
570574
if !config.no_prepopulate_passes {
571575
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);

src/librustc_codegen_llvm/llvm/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl ObjectFile {
190190
pub fn new(llmb: &'static mut MemoryBuffer) -> Option<ObjectFile> {
191191
unsafe {
192192
let llof = LLVMCreateObjectFile(llmb)?;
193-
Some(ObjectFile { llof: llof })
193+
Some(ObjectFile { llof })
194194
}
195195
}
196196
}

src/librustc_codegen_llvm/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ pub fn cleanup_kinds<'a, 'tcx>(mir: &mir::Mir<'tcx>) -> IndexVec<mir::BasicBlock
346346
funclet, succ, kind);
347347
match kind {
348348
CleanupKind::NotCleanup => {
349-
result[succ] = CleanupKind::Internal { funclet: funclet };
349+
result[succ] = CleanupKind::Internal { funclet };
350350
}
351351
CleanupKind::Funclet => {
352352
if funclet != succ {

src/librustc_codegen_utils/symbol_names_test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn report_symbol_names<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
3232
}
3333

3434
tcx.dep_graph.with_ignore(|| {
35-
let mut visitor = SymbolNamesTest { tcx: tcx };
35+
let mut visitor = SymbolNamesTest { tcx };
3636
tcx.hir.krate().visit_all_item_likes(&mut visitor);
3737
})
3838
}

src/librustc_data_structures/flock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ cfg_if! {
214214
unsafe { libc::close(fd); }
215215
Err(err)
216216
} else {
217-
Ok(Lock { fd: fd })
217+
Ok(Lock { fd })
218218
}
219219
}
220220
}

0 commit comments

Comments
 (0)