Skip to content

Commit 6576f4b

Browse files
committed
Auto merge of #65671 - Centril:rollup-00glhmb, r=Centril
Rollup of 7 pull requests Successful merges: - #62330 (Change untagged_unions to not allow union fields with drop) - #65092 (make is_power_of_two a const function) - #65621 (miri: add write_bytes method to Memory doing bounds-checks and supporting iterators) - #65647 (Remove unnecessary trait bounds and derivations) - #65653 (keep the root dir clean from debugging) - #65660 (Rename `ConstValue::Infer(InferConst::Canonical(..))` to `ConstValue::Bound(..)`) - #65663 (Fix typo from #65214) Failed merges: r? @ghost
2 parents 10f12fe + 56756c2 commit 6576f4b

File tree

112 files changed

+667
-482
lines changed

Some content is hidden

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

112 files changed

+667
-482
lines changed

.gitignore

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
# This file should only ignore things that are generated during a build,
2-
# generated by common IDEs, and optional files controlled by the user
3-
# that affect the build (such as config.toml).
1+
# This file should only ignore things that are generated during a `x.py` build,
2+
# generated by common IDEs, and optional files controlled by the user that
3+
# affect the build (such as config.toml).
4+
# In particular, things like `mir_dump` should not be listed here; they are only
5+
# created during manual debugging and many people like to clean up instead of
6+
# having git ignore such leftovers. You can use `.git/info/exclude` to
7+
# configure your local ignore list.
48
# FIXME: This needs cleanup.
59
*~
610
.#*
@@ -52,6 +56,4 @@ config.stamp
5256
Session.vim
5357
.cargo
5458
no_llvm_build
55-
# Generated when dumping Graphviz output for debugging:
56-
/mir_dump/
57-
/*.dot
59+
# Before adding new lines, see the comment at the top.

src/bootstrap/cache.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Ord for Interned<String> {
161161
}
162162
}
163163

164-
struct TyIntern<T: Hash + Clone + Eq> {
164+
struct TyIntern<T: Clone + Eq> {
165165
items: Vec<T>,
166166
set: HashMap<T, Interned<T>>,
167167
}

src/doc/rustc/src/lints/listing/warn-by-default.md

-24
Original file line numberDiff line numberDiff line change
@@ -596,30 +596,6 @@ warning: function cannot return without recursing
596596
|
597597
```
598598

599-
## unions-with-drop-fields
600-
601-
This lint detects use of unions that contain fields with possibly non-trivial drop code. Some
602-
example code that triggers this lint:
603-
604-
```rust
605-
#![feature(untagged_unions)]
606-
607-
union U {
608-
s: String,
609-
}
610-
```
611-
612-
This will produce:
613-
614-
```text
615-
warning: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union
616-
--> src/main.rs:4:5
617-
|
618-
4 | s: String,
619-
| ^^^^^^^^^
620-
|
621-
```
622-
623599
## unknown-lints
624600

625601
This lint detects unrecognized lint attribute. Some

src/libcore/num/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3757,8 +3757,8 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, "
37573757
```"),
37583758
#[stable(feature = "rust1", since = "1.0.0")]
37593759
#[inline]
3760-
pub fn is_power_of_two(self) -> bool {
3761-
(self.wrapping_sub(1)) & self == 0 && !(self == 0)
3760+
pub const fn is_power_of_two(self) -> bool {
3761+
self.count_ones() == 1
37623762
}
37633763
}
37643764

src/librustc/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,5 @@ parking_lot = "0.9"
3636
byteorder = { version = "1.3" }
3737
chalk-engine = { version = "0.9.0", default-features=false }
3838
rustc_fs_util = { path = "../librustc_fs_util" }
39-
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
39+
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
4040
measureme = "0.3"

src/librustc/dep_graph/graph.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl DepNodeIndex {
3535
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
3636
}
3737

38-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
38+
#[derive(PartialEq)]
3939
pub enum DepNodeColor {
4040
Red,
4141
Green(DepNodeIndex)

src/librustc/hir/map/definitions.rs

-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,6 @@ macro_rules! define_global_metadata_kind {
599599
(pub enum GlobalMetaDataKind {
600600
$($variant:ident),*
601601
}) => (
602-
#[derive(Clone, Copy, Debug, Hash, RustcEncodable, RustcDecodable)]
603602
pub enum GlobalMetaDataKind {
604603
$($variant),*
605604
}

src/librustc/hir/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ impl Mutability {
10771077
}
10781078
}
10791079

1080-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Hash, HashStable)]
1080+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
10811081
pub enum BinOpKind {
10821082
/// The `+` operator (addition).
10831083
Add,
@@ -1211,7 +1211,7 @@ impl Into<ast::BinOpKind> for BinOpKind {
12111211

12121212
pub type BinOp = Spanned<BinOpKind>;
12131213

1214-
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, Hash, HashStable)]
1214+
#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, Debug, HashStable)]
12151215
pub enum UnOp {
12161216
/// The `*` operator (deferencing).
12171217
UnDeref,
@@ -1388,8 +1388,7 @@ impl Body {
13881388
}
13891389

13901390
/// The type of source expression that caused this generator to be created.
1391-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
1392-
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1391+
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
13931392
pub enum GeneratorKind {
13941393
/// An explicit `async` block or the body of an async function.
13951394
Async(AsyncGeneratorKind),
@@ -1412,8 +1411,7 @@ impl fmt::Display for GeneratorKind {
14121411
///
14131412
/// This helps error messages but is also used to drive coercions in
14141413
/// type-checking (see #60424).
1415-
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
1416-
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
1414+
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
14171415
pub enum AsyncGeneratorKind {
14181416
/// An explicit `async` block written by the user.
14191417
Block,

src/librustc/hir/ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};
1111

1212
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
1313
/// An owned smart pointer.
14-
#[derive(Hash, PartialEq, Eq)]
14+
#[derive(PartialEq, Eq)]
1515
pub struct P<T: ?Sized> {
1616
ptr: Box<T>
1717
}

src/librustc/infer/canonical/canonicalizer.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
468468
ConstValue::Infer(InferConst::Fresh(_)) => {
469469
bug!("encountered a fresh const during canonicalization")
470470
}
471-
ConstValue::Infer(InferConst::Canonical(debruijn, _)) => {
471+
ConstValue::Bound(debruijn, _) => {
472472
if debruijn >= self.binder_index {
473473
bug!("escaping bound type during canonicalization")
474474
} else {
@@ -700,7 +700,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
700700
let var = self.canonical_var(info, const_var.into());
701701
self.tcx().mk_const(
702702
ty::Const {
703-
val: ConstValue::Infer(InferConst::Canonical(self.binder_index, var.into())),
703+
val: ConstValue::Bound(self.binder_index, var.into()),
704704
ty: self.fold_ty(const_var.ty),
705705
}
706706
)

src/librustc/infer/canonical/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use std::ops::Index;
3333
use syntax::source_map::Span;
3434
use crate::ty::fold::TypeFoldable;
3535
use crate::ty::subst::GenericArg;
36-
use crate::ty::{self, BoundVar, InferConst, Lift, List, Region, TyCtxt};
36+
use crate::ty::{self, BoundVar, Lift, List, Region, TyCtxt};
3737

3838
mod canonicalizer;
3939

@@ -73,7 +73,7 @@ pub struct CanonicalVarValues<'tcx> {
7373
/// various parts of it with canonical variables. This struct stores
7474
/// those replaced bits to remember for when we process the query
7575
/// result.
76-
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
76+
#[derive(Clone, Debug)]
7777
pub struct OriginalQueryValues<'tcx> {
7878
/// Map from the universes that appear in the query to the
7979
/// universes in the caller context. For the time being, we only
@@ -510,9 +510,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
510510
GenericArgKind::Const(ct) => {
511511
tcx.mk_const(ty::Const {
512512
ty: ct.ty,
513-
val: ConstValue::Infer(
514-
InferConst::Canonical(ty::INNERMOST, ty::BoundVar::from_u32(i))
515-
),
513+
val: ConstValue::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i)),
516514
}).into()
517515
}
518516
})

src/librustc/infer/canonical/query_response.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::traits::TraitEngine;
2626
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
2727
use crate::ty::fold::TypeFoldable;
2828
use crate::ty::subst::{GenericArg, GenericArgKind};
29-
use crate::ty::{self, BoundVar, InferConst, Ty, TyCtxt};
29+
use crate::ty::{self, BoundVar, Ty, TyCtxt};
3030
use crate::util::captures::Captures;
3131

3232
impl<'tcx> InferCtxtBuilder<'tcx> {
@@ -493,10 +493,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
493493
}
494494
}
495495
GenericArgKind::Const(result_value) => {
496-
if let ty::Const {
497-
val: ConstValue::Infer(InferConst::Canonical(debrujin, b)),
498-
..
499-
} = result_value {
496+
if let ty::Const { val: ConstValue::Bound(debrujin, b), .. } = result_value {
500497
// ...in which case we would set `canonical_vars[0]` to `Some(const X)`.
501498

502499
// We only allow a `ty::INNERMOST` index in substitutions.

src/librustc/infer/combine.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ pub struct CombineFields<'infcx, 'tcx> {
5353
pub obligations: PredicateObligations<'tcx>,
5454
}
5555

56-
#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
56+
#[derive(Copy, Clone, Debug)]
5757
pub enum RelationDir {
5858
SubtypeOf, SupertypeOf, EqTo
5959
}

src/librustc/infer/freshen.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
252252
return ct;
253253
}
254254

255-
ConstValue::Infer(ty::InferConst::Canonical(..)) |
255+
ConstValue::Bound(..) |
256256
ConstValue::Placeholder(_) => {
257257
bug!("unexpected const {:?}", ct)
258258
}

src/librustc/infer/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub enum RegionVariableOrigin {
407407
NLL(NLLRegionVariableOrigin),
408408
}
409409

410-
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
410+
#[derive(Copy, Clone, Debug)]
411411
pub enum NLLRegionVariableOrigin {
412412
/// During NLL region processing, we create variables for free
413413
/// regions that we encounter in the function signature and

src/librustc/infer/nll_relate/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ use crate::ty::error::TypeError;
2727
use crate::ty::fold::{TypeFoldable, TypeVisitor};
2828
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
2929
use crate::ty::subst::GenericArg;
30-
use crate::ty::{self, Ty, TyCtxt, InferConst};
30+
use crate::ty::{self, Ty, TyCtxt};
3131
use crate::mir::interpret::ConstValue;
3232
use rustc_data_structures::fx::FxHashMap;
3333
use std::fmt::Debug;
3434

35-
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
35+
#[derive(PartialEq)]
3636
pub enum NormalizationStrategy {
3737
Lazy,
3838
Eager,
@@ -618,7 +618,7 @@ where
618618
a: &'tcx ty::Const<'tcx>,
619619
b: &'tcx ty::Const<'tcx>,
620620
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
621-
if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(_, _)), .. } = a {
621+
if let ty::Const { val: ConstValue::Bound(..), .. } = a {
622622
// FIXME(const_generics): I'm unsure how this branch should actually be handled,
623623
// so this is probably not correct.
624624
self.infcx.super_combine_consts(self, a, b)
@@ -993,7 +993,7 @@ where
993993
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
994994
debug!("TypeGeneralizer::consts(a={:?})", a);
995995

996-
if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(_, _)), .. } = a {
996+
if let ty::Const { val: ConstValue::Bound(..), .. } = a {
997997
bug!(
998998
"unexpected inference variable encountered in NLL generalization: {:?}",
999999
a

src/librustc/infer/region_constraints/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub struct RegionConstraintData<'tcx> {
116116
}
117117

118118
/// Represents a constraint that influences the inference process.
119-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
119+
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
120120
pub enum Constraint<'tcx> {
121121
/// A region variable is a subregion of another.
122122
VarSubVar(RegionVid, RegionVid),

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#![feature(nll)]
4444
#![feature(non_exhaustive)]
4545
#![feature(optin_builtin_traits)]
46+
#![feature(option_expect_none)]
4647
#![feature(range_is_empty)]
4748
#![feature(slice_patterns)]
4849
#![feature(specialization)]

src/librustc/middle/cstore.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ pub struct NativeLibrary {
117117
pub wasm_import_module: Option<Symbol>,
118118
}
119119

120-
#[derive(Clone, Hash, RustcEncodable, RustcDecodable, HashStable)]
120+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
121121
pub struct ForeignModule {
122122
pub foreign_items: Vec<DefId>,
123123
pub def_id: DefId,

src/librustc/middle/mem_categorization.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub struct Upvar {
102102
}
103103

104104
// different kinds of pointers:
105-
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
105+
#[derive(Clone, Copy, Debug, PartialEq)]
106106
pub enum PointerKind<'tcx> {
107107
/// `Box<T>`
108108
Unique,
@@ -116,7 +116,7 @@ pub enum PointerKind<'tcx> {
116116

117117
// We use the term "interior" to mean "something reachable from the
118118
// base without a pointer dereference", e.g., a field
119-
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
119+
#[derive(Clone, PartialEq)]
120120
pub enum InteriorKind {
121121
InteriorField(FieldIndex),
122122
InteriorElement(InteriorOffsetKind),
@@ -139,13 +139,13 @@ impl Hash for FieldIndex {
139139
}
140140
}
141141

142-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
142+
#[derive(Clone, PartialEq)]
143143
pub enum InteriorOffsetKind {
144144
Index, // e.g., `array_expr[index_expr]`
145145
Pattern, // e.g., `fn foo([_, a, _, _]: [A; 4]) { ... }`
146146
}
147147

148-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
148+
#[derive(Clone, Copy, PartialEq, Debug)]
149149
pub enum MutabilityCategory {
150150
McImmutable, // Immutable.
151151
McDeclared, // Directly declared as mutable.

src/librustc/middle/stability.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::util::nodemap::{FxHashSet, FxHashMap};
2525
use std::mem::replace;
2626
use std::cmp::Ordering;
2727

28-
#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)]
28+
#[derive(PartialEq, Clone, Copy, Debug)]
2929
pub enum StabilityLevel {
3030
Unstable,
3131
Stable,

0 commit comments

Comments
 (0)