Skip to content

Commit

Permalink
Auto merge of #65671 - Centril:rollup-00glhmb, r=Centril
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Oct 22, 2019
2 parents 10f12fe + 56756c2 commit 6576f4b
Show file tree
Hide file tree
Showing 112 changed files with 667 additions and 482 deletions.
14 changes: 8 additions & 6 deletions .gitignore
@@ -1,6 +1,10 @@
# This file should only ignore things that are generated during a build,
# generated by common IDEs, and optional files controlled by the user
# that affect the build (such as config.toml).
# This file should only ignore things that are generated during a `x.py` build,
# generated by common IDEs, and optional files controlled by the user that
# affect the build (such as config.toml).
# In particular, things like `mir_dump` should not be listed here; they are only
# created during manual debugging and many people like to clean up instead of
# having git ignore such leftovers. You can use `.git/info/exclude` to
# configure your local ignore list.
# FIXME: This needs cleanup.
*~
.#*
Expand Down Expand Up @@ -52,6 +56,4 @@ config.stamp
Session.vim
.cargo
no_llvm_build
# Generated when dumping Graphviz output for debugging:
/mir_dump/
/*.dot
# Before adding new lines, see the comment at the top.
2 changes: 1 addition & 1 deletion src/bootstrap/cache.rs
Expand Up @@ -161,7 +161,7 @@ impl Ord for Interned<String> {
}
}

struct TyIntern<T: Hash + Clone + Eq> {
struct TyIntern<T: Clone + Eq> {
items: Vec<T>,
set: HashMap<T, Interned<T>>,
}
Expand Down
24 changes: 0 additions & 24 deletions src/doc/rustc/src/lints/listing/warn-by-default.md
Expand Up @@ -596,30 +596,6 @@ warning: function cannot return without recursing
|
```

## unions-with-drop-fields

This lint detects use of unions that contain fields with possibly non-trivial drop code. Some
example code that triggers this lint:

```rust
#![feature(untagged_unions)]

union U {
s: String,
}
```

This will produce:

```text
warning: union contains a field with possibly non-trivial drop code, drop code of union fields is ignored when dropping the union
--> src/main.rs:4:5
|
4 | s: String,
| ^^^^^^^^^
|
```

## unknown-lints

This lint detects unrecognized lint attribute. Some
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/num/mod.rs
Expand Up @@ -3757,8 +3757,8 @@ assert!(!10", stringify!($SelfT), ".is_power_of_two());", $EndFeature, "
```"),
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub fn is_power_of_two(self) -> bool {
(self.wrapping_sub(1)) & self == 0 && !(self == 0)
pub const fn is_power_of_two(self) -> bool {
self.count_ones() == 1
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/Cargo.toml
Expand Up @@ -36,5 +36,5 @@ parking_lot = "0.9"
byteorder = { version = "1.3" }
chalk-engine = { version = "0.9.0", default-features=false }
rustc_fs_util = { path = "../librustc_fs_util" }
smallvec = { version = "0.6.7", features = ["union", "may_dangle"] }
smallvec = { version = "0.6.8", features = ["union", "may_dangle"] }
measureme = "0.3"
2 changes: 1 addition & 1 deletion src/librustc/dep_graph/graph.rs
Expand Up @@ -35,7 +35,7 @@ impl DepNodeIndex {
pub const INVALID: DepNodeIndex = DepNodeIndex::MAX;
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(PartialEq)]
pub enum DepNodeColor {
Red,
Green(DepNodeIndex)
Expand Down
1 change: 0 additions & 1 deletion src/librustc/hir/map/definitions.rs
Expand Up @@ -599,7 +599,6 @@ macro_rules! define_global_metadata_kind {
(pub enum GlobalMetaDataKind {
$($variant:ident),*
}) => (
#[derive(Clone, Copy, Debug, Hash, RustcEncodable, RustcDecodable)]
pub enum GlobalMetaDataKind {
$($variant),*
}
Expand Down
10 changes: 4 additions & 6 deletions src/librustc/hir/mod.rs
Expand Up @@ -1077,7 +1077,7 @@ impl Mutability {
}
}

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

pub type BinOp = Spanned<BinOpKind>;

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

/// The type of source expression that caused this generator to be created.
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum GeneratorKind {
/// An explicit `async` block or the body of an async function.
Async(AsyncGeneratorKind),
Expand All @@ -1412,8 +1411,7 @@ impl fmt::Display for GeneratorKind {
///
/// This helps error messages but is also used to drive coercions in
/// type-checking (see #60424).
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, HashStable,
RustcEncodable, RustcDecodable, Hash, Debug, Copy)]
#[derive(Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable, Debug, Copy)]
pub enum AsyncGeneratorKind {
/// An explicit `async` block written by the user.
Block,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/ptr.rs
Expand Up @@ -11,7 +11,7 @@ use rustc_serialize::{Encodable, Decodable, Encoder, Decoder};

use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
/// An owned smart pointer.
#[derive(Hash, PartialEq, Eq)]
#[derive(PartialEq, Eq)]
pub struct P<T: ?Sized> {
ptr: Box<T>
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/infer/canonical/canonicalizer.rs
Expand Up @@ -468,7 +468,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
ConstValue::Infer(InferConst::Fresh(_)) => {
bug!("encountered a fresh const during canonicalization")
}
ConstValue::Infer(InferConst::Canonical(debruijn, _)) => {
ConstValue::Bound(debruijn, _) => {
if debruijn >= self.binder_index {
bug!("escaping bound type during canonicalization")
} else {
Expand Down Expand Up @@ -700,7 +700,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
let var = self.canonical_var(info, const_var.into());
self.tcx().mk_const(
ty::Const {
val: ConstValue::Infer(InferConst::Canonical(self.binder_index, var.into())),
val: ConstValue::Bound(self.binder_index, var.into()),
ty: self.fold_ty(const_var.ty),
}
)
Expand Down
8 changes: 3 additions & 5 deletions src/librustc/infer/canonical/mod.rs
Expand Up @@ -33,7 +33,7 @@ use std::ops::Index;
use syntax::source_map::Span;
use crate::ty::fold::TypeFoldable;
use crate::ty::subst::GenericArg;
use crate::ty::{self, BoundVar, InferConst, Lift, List, Region, TyCtxt};
use crate::ty::{self, BoundVar, Lift, List, Region, TyCtxt};

mod canonicalizer;

Expand Down Expand Up @@ -73,7 +73,7 @@ pub struct CanonicalVarValues<'tcx> {
/// various parts of it with canonical variables. This struct stores
/// those replaced bits to remember for when we process the query
/// result.
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcDecodable, RustcEncodable)]
#[derive(Clone, Debug)]
pub struct OriginalQueryValues<'tcx> {
/// Map from the universes that appear in the query to the
/// universes in the caller context. For the time being, we only
Expand Down Expand Up @@ -510,9 +510,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
GenericArgKind::Const(ct) => {
tcx.mk_const(ty::Const {
ty: ct.ty,
val: ConstValue::Infer(
InferConst::Canonical(ty::INNERMOST, ty::BoundVar::from_u32(i))
),
val: ConstValue::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i)),
}).into()
}
})
Expand Down
7 changes: 2 additions & 5 deletions src/librustc/infer/canonical/query_response.rs
Expand Up @@ -26,7 +26,7 @@ use crate::traits::TraitEngine;
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
use crate::ty::fold::TypeFoldable;
use crate::ty::subst::{GenericArg, GenericArgKind};
use crate::ty::{self, BoundVar, InferConst, Ty, TyCtxt};
use crate::ty::{self, BoundVar, Ty, TyCtxt};
use crate::util::captures::Captures;

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

// We only allow a `ty::INNERMOST` index in substitutions.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/combine.rs
Expand Up @@ -53,7 +53,7 @@ pub struct CombineFields<'infcx, 'tcx> {
pub obligations: PredicateObligations<'tcx>,
}

#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)]
#[derive(Copy, Clone, Debug)]
pub enum RelationDir {
SubtypeOf, SupertypeOf, EqTo
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/freshen.rs
Expand Up @@ -252,7 +252,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
return ct;
}

ConstValue::Infer(ty::InferConst::Canonical(..)) |
ConstValue::Bound(..) |
ConstValue::Placeholder(_) => {
bug!("unexpected const {:?}", ct)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Expand Up @@ -407,7 +407,7 @@ pub enum RegionVariableOrigin {
NLL(NLLRegionVariableOrigin),
}

#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, Debug)]
pub enum NLLRegionVariableOrigin {
/// During NLL region processing, we create variables for free
/// regions that we encounter in the function signature and
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/infer/nll_relate/mod.rs
Expand Up @@ -27,12 +27,12 @@ use crate::ty::error::TypeError;
use crate::ty::fold::{TypeFoldable, TypeVisitor};
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
use crate::ty::subst::GenericArg;
use crate::ty::{self, Ty, TyCtxt, InferConst};
use crate::ty::{self, Ty, TyCtxt};
use crate::mir::interpret::ConstValue;
use rustc_data_structures::fx::FxHashMap;
use std::fmt::Debug;

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

if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(_, _)), .. } = a {
if let ty::Const { val: ConstValue::Bound(..), .. } = a {
bug!(
"unexpected inference variable encountered in NLL generalization: {:?}",
a
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/region_constraints/mod.rs
Expand Up @@ -116,7 +116,7 @@ pub struct RegionConstraintData<'tcx> {
}

/// Represents a constraint that influences the inference process.
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
#[derive(Clone, Copy, PartialEq, Eq, Debug, PartialOrd, Ord)]
pub enum Constraint<'tcx> {
/// A region variable is a subregion of another.
VarSubVar(RegionVid, RegionVid),
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Expand Up @@ -43,6 +43,7 @@
#![feature(nll)]
#![feature(non_exhaustive)]
#![feature(optin_builtin_traits)]
#![feature(option_expect_none)]
#![feature(range_is_empty)]
#![feature(slice_patterns)]
#![feature(specialization)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/cstore.rs
Expand Up @@ -117,7 +117,7 @@ pub struct NativeLibrary {
pub wasm_import_module: Option<Symbol>,
}

#[derive(Clone, Hash, RustcEncodable, RustcDecodable, HashStable)]
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub struct ForeignModule {
pub foreign_items: Vec<DefId>,
pub def_id: DefId,
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/middle/mem_categorization.rs
Expand Up @@ -102,7 +102,7 @@ pub struct Upvar {
}

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

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

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

#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
#[derive(Clone, Copy, PartialEq, Debug)]
pub enum MutabilityCategory {
McImmutable, // Immutable.
McDeclared, // Directly declared as mutable.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/stability.rs
Expand Up @@ -25,7 +25,7 @@ use crate::util::nodemap::{FxHashSet, FxHashMap};
use std::mem::replace;
use std::cmp::Ordering;

#[derive(RustcEncodable, RustcDecodable, PartialEq, PartialOrd, Clone, Copy, Debug, Eq, Hash)]
#[derive(PartialEq, Clone, Copy, Debug)]
pub enum StabilityLevel {
Unstable,
Stable,
Expand Down

0 comments on commit 6576f4b

Please sign in to comment.