Skip to content

Commit c6e4db6

Browse files
committed
Auto merge of #77198 - jonas-schievink:rollup-i59i41h, r=jonas-schievink
Rollup of 15 pull requests Successful merges: - #76932 (Relax promises about condition variable.) - #76973 (Unstably allow assume intrinsic in const contexts) - #77005 (BtreeMap: refactoring around edges) - #77066 (Fix dest prop miscompilation around references) - #77073 (dead_code: look at trait impls even if they don't contain items) - #77086 (Include libunwind in the rust-src component.) - #77097 (Make [].as_[mut_]ptr_range() (unstably) const.) - #77106 (clarify that `changelog-seen = 1` goes to the beginning of config.toml) - #77120 (Add `--keep-stage-std` to `x.py` for keeping only standard library artifacts) - #77126 (Invalidate local LLVM cache less often) - #77146 (Install std for non-host targets) - #77155 (remove enum name from ImplSource variants) - #77176 (Removing erroneous semicolon in transmute documentation) - #77183 (Allow multiple allow_internal_unstable attributes) - #77189 (Remove extra space from vec drawing) Failed merges: r? `@ghost`
2 parents 10ef7f9 + d72b7cc commit c6e4db6

File tree

45 files changed

+576
-452
lines changed

Some content is hidden

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

45 files changed

+576
-452
lines changed

compiler/rustc_attr/src/builtin.rs

+14-7
Original file line numberDiff line numberDiff line change
@@ -1022,14 +1022,21 @@ pub fn find_transparency(
10221022

10231023
pub fn allow_internal_unstable<'a>(
10241024
sess: &'a Session,
1025-
attrs: &[Attribute],
1025+
attrs: &'a [Attribute],
10261026
) -> Option<impl Iterator<Item = Symbol> + 'a> {
1027-
let attr = sess.find_by_name(attrs, sym::allow_internal_unstable)?;
1028-
let list = attr.meta_item_list().or_else(|| {
1029-
sess.diagnostic()
1030-
.span_err(attr.span, "allow_internal_unstable expects list of feature names");
1031-
None
1032-
})?;
1027+
let attrs = sess.filter_by_name(attrs, sym::allow_internal_unstable);
1028+
let list = attrs
1029+
.filter_map(move |attr| {
1030+
attr.meta_item_list().or_else(|| {
1031+
sess.diagnostic().span_err(
1032+
attr.span,
1033+
"`allow_internal_unstable` expects a list of feature names",
1034+
);
1035+
None
1036+
})
1037+
})
1038+
.flatten();
1039+
10331040
Some(list.into_iter().filter_map(move |it| {
10341041
let name = it.ident().map(|ident| ident.name);
10351042
if name.is_none() {

compiler/rustc_codegen_ssa/src/traits/intrinsic.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use rustc_span::Span;
55
use rustc_target::abi::call::FnAbi;
66

77
pub trait IntrinsicCallMethods<'tcx>: BackendTypes {
8-
/// Remember to add all intrinsics here, in librustc_typeck/check/mod.rs,
9-
/// and in libcore/intrinsics.rs; if you need access to any llvm intrinsics,
10-
/// add them to librustc_codegen_llvm/context.rs
8+
/// Remember to add all intrinsics here, in `compiler/rustc_typeck/src/check/mod.rs`,
9+
/// and in `library/core/src/intrinsics.rs`; if you need access to any LLVM intrinsics,
10+
/// add them to `compiler/rustc_codegen_llvm/src/context.rs`.
1111
fn codegen_intrinsic_call(
1212
&mut self,
1313
instance: ty::Instance<'tcx>,

compiler/rustc_error_codes/src/error_codes/E0092.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ extern "rust-intrinsic" {
1212
```
1313

1414
Please check you didn't make a mistake in the function's name. All intrinsic
15-
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
16-
`libcore/intrinsics.rs` in the Rust source code. Example:
15+
functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
16+
`library/core/src/intrinsics.rs` in the Rust source code. Example:
1717

1818
```
1919
#![feature(intrinsics)]

compiler/rustc_error_codes/src/error_codes/E0093.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn main() {
1717
```
1818

1919
Please check you didn't make a mistake in the function's name. All intrinsic
20-
functions are defined in `librustc_codegen_llvm/intrinsic.rs` and in
21-
`libcore/intrinsics.rs` in the Rust source code. Example:
20+
functions are defined in `compiler/rustc_codegen_llvm/src/intrinsic.rs` and in
21+
`library/core/src/intrinsics.rs` in the Rust source code. Example:
2222

2323
```
2424
#![feature(intrinsics)]

compiler/rustc_middle/src/traits/mod.rs

+44-45
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ pub use self::select::{EvaluationCache, EvaluationResult, OverflowError, Selecti
2828

2929
pub type CanonicalChalkEnvironmentAndGoal<'tcx> = Canonical<'tcx, ChalkEnvironmentAndGoal<'tcx>>;
3030

31-
pub use self::ImplSource::*;
3231
pub use self::ObligationCauseCode::*;
3332

3433
pub use self::chalk::{ChalkEnvironmentAndGoal, RustInterner as ChalkRustInterner};
@@ -418,10 +417,10 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
418417
///
419418
/// // Case B: ImplSource must be provided by caller. This applies when
420419
/// // type is a type parameter.
421-
/// param.clone(); // ImplSourceParam
420+
/// param.clone(); // ImplSource::Param
422421
///
423422
/// // Case C: A mix of cases A and B.
424-
/// mixed.clone(); // ImplSource(Impl_1, [ImplSourceParam])
423+
/// mixed.clone(); // ImplSource(Impl_1, [ImplSource::Param])
425424
/// }
426425
/// ```
427426
///
@@ -431,72 +430,72 @@ pub type SelectionResult<'tcx, T> = Result<Option<T>, SelectionError<'tcx>>;
431430
#[derive(Clone, PartialEq, Eq, TyEncodable, TyDecodable, HashStable, TypeFoldable, Lift)]
432431
pub enum ImplSource<'tcx, N> {
433432
/// ImplSource identifying a particular impl.
434-
ImplSourceUserDefined(ImplSourceUserDefinedData<'tcx, N>),
433+
UserDefined(ImplSourceUserDefinedData<'tcx, N>),
435434

436435
/// ImplSource for auto trait implementations.
437436
/// This carries the information and nested obligations with regards
438437
/// to an auto implementation for a trait `Trait`. The nested obligations
439438
/// ensure the trait implementation holds for all the constituent types.
440-
ImplSourceAutoImpl(ImplSourceAutoImplData<N>),
439+
AutoImpl(ImplSourceAutoImplData<N>),
441440

442441
/// Successful resolution to an obligation provided by the caller
443442
/// for some type parameter. The `Vec<N>` represents the
444443
/// obligations incurred from normalizing the where-clause (if
445444
/// any).
446-
ImplSourceParam(Vec<N>),
445+
Param(Vec<N>),
447446

448447
/// Virtual calls through an object.
449-
ImplSourceObject(ImplSourceObjectData<'tcx, N>),
448+
Object(ImplSourceObjectData<'tcx, N>),
450449

451450
/// Successful resolution for a builtin trait.
452-
ImplSourceBuiltin(ImplSourceBuiltinData<N>),
451+
Builtin(ImplSourceBuiltinData<N>),
453452

454453
/// ImplSource automatically generated for a closure. The `DefId` is the ID
455-
/// of the closure expression. This is a `ImplSourceUserDefined` in spirit, but the
454+
/// of the closure expression. This is a `ImplSource::UserDefined` in spirit, but the
456455
/// impl is generated by the compiler and does not appear in the source.
457-
ImplSourceClosure(ImplSourceClosureData<'tcx, N>),
456+
Closure(ImplSourceClosureData<'tcx, N>),
458457

459458
/// Same as above, but for a function pointer type with the given signature.
460-
ImplSourceFnPointer(ImplSourceFnPointerData<'tcx, N>),
459+
FnPointer(ImplSourceFnPointerData<'tcx, N>),
461460

462461
/// ImplSource for a builtin `DeterminantKind` trait implementation.
463-
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData),
462+
DiscriminantKind(ImplSourceDiscriminantKindData),
464463

465464
/// ImplSource automatically generated for a generator.
466-
ImplSourceGenerator(ImplSourceGeneratorData<'tcx, N>),
465+
Generator(ImplSourceGeneratorData<'tcx, N>),
467466

468467
/// ImplSource for a trait alias.
469-
ImplSourceTraitAlias(ImplSourceTraitAliasData<'tcx, N>),
468+
TraitAlias(ImplSourceTraitAliasData<'tcx, N>),
470469
}
471470

472471
impl<'tcx, N> ImplSource<'tcx, N> {
473472
pub fn nested_obligations(self) -> Vec<N> {
474473
match self {
475-
ImplSourceUserDefined(i) => i.nested,
476-
ImplSourceParam(n) => n,
477-
ImplSourceBuiltin(i) => i.nested,
478-
ImplSourceAutoImpl(d) => d.nested,
479-
ImplSourceClosure(c) => c.nested,
480-
ImplSourceGenerator(c) => c.nested,
481-
ImplSourceObject(d) => d.nested,
482-
ImplSourceFnPointer(d) => d.nested,
483-
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => Vec::new(),
484-
ImplSourceTraitAlias(d) => d.nested,
474+
ImplSource::UserDefined(i) => i.nested,
475+
ImplSource::Param(n) => n,
476+
ImplSource::Builtin(i) => i.nested,
477+
ImplSource::AutoImpl(d) => d.nested,
478+
ImplSource::Closure(c) => c.nested,
479+
ImplSource::Generator(c) => c.nested,
480+
ImplSource::Object(d) => d.nested,
481+
ImplSource::FnPointer(d) => d.nested,
482+
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => Vec::new(),
483+
ImplSource::TraitAlias(d) => d.nested,
485484
}
486485
}
487486

488487
pub fn borrow_nested_obligations(&self) -> &[N] {
489488
match &self {
490-
ImplSourceUserDefined(i) => &i.nested[..],
491-
ImplSourceParam(n) => &n[..],
492-
ImplSourceBuiltin(i) => &i.nested[..],
493-
ImplSourceAutoImpl(d) => &d.nested[..],
494-
ImplSourceClosure(c) => &c.nested[..],
495-
ImplSourceGenerator(c) => &c.nested[..],
496-
ImplSourceObject(d) => &d.nested[..],
497-
ImplSourceFnPointer(d) => &d.nested[..],
498-
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => &[],
499-
ImplSourceTraitAlias(d) => &d.nested[..],
489+
ImplSource::UserDefined(i) => &i.nested[..],
490+
ImplSource::Param(n) => &n[..],
491+
ImplSource::Builtin(i) => &i.nested[..],
492+
ImplSource::AutoImpl(d) => &d.nested[..],
493+
ImplSource::Closure(c) => &c.nested[..],
494+
ImplSource::Generator(c) => &c.nested[..],
495+
ImplSource::Object(d) => &d.nested[..],
496+
ImplSource::FnPointer(d) => &d.nested[..],
497+
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => &[],
498+
ImplSource::TraitAlias(d) => &d.nested[..],
500499
}
501500
}
502501

@@ -505,42 +504,42 @@ impl<'tcx, N> ImplSource<'tcx, N> {
505504
F: FnMut(N) -> M,
506505
{
507506
match self {
508-
ImplSourceUserDefined(i) => ImplSourceUserDefined(ImplSourceUserDefinedData {
507+
ImplSource::UserDefined(i) => ImplSource::UserDefined(ImplSourceUserDefinedData {
509508
impl_def_id: i.impl_def_id,
510509
substs: i.substs,
511510
nested: i.nested.into_iter().map(f).collect(),
512511
}),
513-
ImplSourceParam(n) => ImplSourceParam(n.into_iter().map(f).collect()),
514-
ImplSourceBuiltin(i) => ImplSourceBuiltin(ImplSourceBuiltinData {
512+
ImplSource::Param(n) => ImplSource::Param(n.into_iter().map(f).collect()),
513+
ImplSource::Builtin(i) => ImplSource::Builtin(ImplSourceBuiltinData {
515514
nested: i.nested.into_iter().map(f).collect(),
516515
}),
517-
ImplSourceObject(o) => ImplSourceObject(ImplSourceObjectData {
516+
ImplSource::Object(o) => ImplSource::Object(ImplSourceObjectData {
518517
upcast_trait_ref: o.upcast_trait_ref,
519518
vtable_base: o.vtable_base,
520519
nested: o.nested.into_iter().map(f).collect(),
521520
}),
522-
ImplSourceAutoImpl(d) => ImplSourceAutoImpl(ImplSourceAutoImplData {
521+
ImplSource::AutoImpl(d) => ImplSource::AutoImpl(ImplSourceAutoImplData {
523522
trait_def_id: d.trait_def_id,
524523
nested: d.nested.into_iter().map(f).collect(),
525524
}),
526-
ImplSourceClosure(c) => ImplSourceClosure(ImplSourceClosureData {
525+
ImplSource::Closure(c) => ImplSource::Closure(ImplSourceClosureData {
527526
closure_def_id: c.closure_def_id,
528527
substs: c.substs,
529528
nested: c.nested.into_iter().map(f).collect(),
530529
}),
531-
ImplSourceGenerator(c) => ImplSourceGenerator(ImplSourceGeneratorData {
530+
ImplSource::Generator(c) => ImplSource::Generator(ImplSourceGeneratorData {
532531
generator_def_id: c.generator_def_id,
533532
substs: c.substs,
534533
nested: c.nested.into_iter().map(f).collect(),
535534
}),
536-
ImplSourceFnPointer(p) => ImplSourceFnPointer(ImplSourceFnPointerData {
535+
ImplSource::FnPointer(p) => ImplSource::FnPointer(ImplSourceFnPointerData {
537536
fn_ty: p.fn_ty,
538537
nested: p.nested.into_iter().map(f).collect(),
539538
}),
540-
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData) => {
541-
ImplSourceDiscriminantKind(ImplSourceDiscriminantKindData)
539+
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData) => {
540+
ImplSource::DiscriminantKind(ImplSourceDiscriminantKindData)
542541
}
543-
ImplSourceTraitAlias(d) => ImplSourceTraitAlias(ImplSourceTraitAliasData {
542+
ImplSource::TraitAlias(d) => ImplSource::TraitAlias(ImplSourceTraitAliasData {
544543
alias_def_id: d.alias_def_id,
545544
substs: d.substs,
546545
nested: d.nested.into_iter().map(f).collect(),

compiler/rustc_middle/src/traits/structural_impls.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@ use std::fmt;
77
impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSource<'tcx, N> {
88
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
99
match *self {
10-
super::ImplSourceUserDefined(ref v) => write!(f, "{:?}", v),
10+
super::ImplSource::UserDefined(ref v) => write!(f, "{:?}", v),
1111

12-
super::ImplSourceAutoImpl(ref t) => write!(f, "{:?}", t),
12+
super::ImplSource::AutoImpl(ref t) => write!(f, "{:?}", t),
1313

14-
super::ImplSourceClosure(ref d) => write!(f, "{:?}", d),
14+
super::ImplSource::Closure(ref d) => write!(f, "{:?}", d),
1515

16-
super::ImplSourceGenerator(ref d) => write!(f, "{:?}", d),
16+
super::ImplSource::Generator(ref d) => write!(f, "{:?}", d),
1717

18-
super::ImplSourceFnPointer(ref d) => write!(f, "ImplSourceFnPointer({:?})", d),
18+
super::ImplSource::FnPointer(ref d) => write!(f, "({:?})", d),
1919

20-
super::ImplSourceDiscriminantKind(ref d) => write!(f, "{:?}", d),
20+
super::ImplSource::DiscriminantKind(ref d) => write!(f, "{:?}", d),
2121

22-
super::ImplSourceObject(ref d) => write!(f, "{:?}", d),
22+
super::ImplSource::Object(ref d) => write!(f, "{:?}", d),
2323

24-
super::ImplSourceParam(ref n) => write!(f, "ImplSourceParam({:?})", n),
24+
super::ImplSource::Param(ref n) => write!(f, "ImplSourceParamData({:?})", n),
2525

26-
super::ImplSourceBuiltin(ref d) => write!(f, "{:?}", d),
26+
super::ImplSource::Builtin(ref d) => write!(f, "{:?}", d),
2727

28-
super::ImplSourceTraitAlias(ref d) => write!(f, "{:?}", d),
28+
super::ImplSource::TraitAlias(ref d) => write!(f, "{:?}", d),
2929
}
3030
}
3131
}
@@ -96,7 +96,7 @@ impl<'tcx, N: fmt::Debug> fmt::Debug for traits::ImplSourceTraitAliasData<'tcx,
9696
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
9797
write!(
9898
f,
99-
"ImplSourceTraitAlias(alias_def_id={:?}, substs={:?}, nested={:?})",
99+
"ImplSourceTraitAliasData(alias_def_id={:?}, substs={:?}, nested={:?})",
100100
self.alias_def_id, self.substs, self.nested
101101
)
102102
}

compiler/rustc_mir/src/interpret/intrinsics.rs

+6
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
435435
// These just return their argument
436436
self.copy_op(args[0], dest)?;
437437
}
438+
sym::assume => {
439+
let cond = self.read_scalar(args[0])?.check_init()?.to_bool()?;
440+
if !cond {
441+
throw_ub_format!("`assume` intrinsic called with `false`");
442+
}
443+
}
438444
_ => return Ok(false),
439445
}
440446

compiler/rustc_mir/src/interpret/terminator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
390390
ty::InstanceDef::Virtual(_, idx) => {
391391
let mut args = args.to_vec();
392392
// We have to implement all "object safe receivers". Currently we
393-
// support built-in pointers (&, &mut, Box) as well as unsized-self. We do
393+
// support built-in pointers `(&, &mut, Box)` as well as unsized-self. We do
394394
// not yet support custom self types.
395-
// Also see librustc_codegen_llvm/abi.rs and librustc_codegen_llvm/mir/block.rs.
395+
// Also see `compiler/rustc_codegen_llvm/src/abi.rs` and `compiler/rustc_codegen_ssa/src/mir/block.rs`.
396396
let receiver_place = match args[0].layout.ty.builtin_deref(true) {
397397
Some(_) => {
398398
// Built-in pointer.

compiler/rustc_mir/src/monomorphize/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn custom_coerce_unsize_info<'tcx>(
2121
});
2222

2323
match tcx.codegen_fulfill_obligation((ty::ParamEnv::reveal_all(), trait_ref)) {
24-
Ok(traits::ImplSourceUserDefined(traits::ImplSourceUserDefinedData {
24+
Ok(traits::ImplSource::UserDefined(traits::ImplSourceUserDefinedData {
2525
impl_def_id,
2626
..
2727
})) => tcx.coerce_unsized_info(impl_def_id).custom_kind.unwrap(),

compiler/rustc_mir/src/transform/dest_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ impl<'a, 'tcx> Visitor<'tcx> for FindAssignments<'a, 'tcx> {
905905
// FIXME: This can be smarter and take `StorageDead` into account (which
906906
// invalidates borrows).
907907
if self.ever_borrowed_locals.contains(dest.local)
908-
&& self.ever_borrowed_locals.contains(src.local)
908+
|| self.ever_borrowed_locals.contains(src.local)
909909
{
910910
return;
911911
}

compiler/rustc_passes/src/dead.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ fn has_allow_dead_code_or_lang_attr(
369369
// - This is because lang items are always callable from elsewhere.
370370
// or
371371
// 2) We are not sure to be live or not
372-
// * Implementation of a trait method
372+
// * Implementations of traits and trait methods
373373
struct LifeSeeder<'k, 'tcx> {
374374
worklist: Vec<hir::HirId>,
375375
krate: &'k hir::Crate<'k>,
@@ -415,6 +415,9 @@ impl<'v, 'k, 'tcx> ItemLikeVisitor<'v> for LifeSeeder<'k, 'tcx> {
415415
}
416416
}
417417
hir::ItemKind::Impl { ref of_trait, items, .. } => {
418+
if of_trait.is_some() {
419+
self.worklist.push(item.hir_id);
420+
}
418421
for impl_item_ref in items {
419422
let impl_item = self.krate.impl_item(impl_item_ref.id);
420423
if of_trait.is_some()

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'tcx> AutoTraitFinder<'tcx> {
9696
));
9797

9898
match result {
99-
Ok(Some(ImplSource::ImplSourceUserDefined(_))) => {
99+
Ok(Some(ImplSource::UserDefined(_))) => {
100100
debug!(
101101
"find_auto_trait_generics({:?}): \
102102
manual impl found, bailing out",
@@ -315,9 +315,8 @@ impl AutoTraitFinder<'tcx> {
315315
// If we see an explicit negative impl (e.g., `impl !Send for MyStruct`),
316316
// we immediately bail out, since it's impossible for us to continue.
317317

318-
if let ImplSource::ImplSourceUserDefined(ImplSourceUserDefinedData {
319-
impl_def_id,
320-
..
318+
if let ImplSource::UserDefined(ImplSourceUserDefinedData {
319+
impl_def_id, ..
321320
}) = impl_source
322321
{
323322
// Blame 'tidy' for the weird bracket placement.

0 commit comments

Comments
 (0)