Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 7 pull requests #65671

Merged
merged 40 commits into from Oct 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a12788a
make is_power_of_two a const function
tspiteri Aug 22, 2019
0a08841
Remove uses of `allow(unions_with_drop_fields)` in the standard library
SimonSapin Jul 3, 2019
84ca0a1
Remove most uses of `allow(unions_with_drop_fields)` in tests
SimonSapin Jul 3, 2019
2f0c821
Change untagged_unions to not allow union fields with drop
bluss Dec 19, 2018
fe13bbd
Remove unions_with_drop_fields lint
SimonSapin Jul 3, 2019
e247a40
Fixes #41073, it is no longer an ICE
SimonSapin Jul 3, 2019
05a644e
Update src/librustc_typeck/check/mod.rs
SimonSapin Jul 4, 2019
8c5ae86
Update src/librustc_typeck/check/mod.rs
SimonSapin Jul 4, 2019
0301eaf
Update src/librustc_typeck/error_codes.rs
SimonSapin Jul 4, 2019
bf25a9c
Update src/test/run-pass/union/union-nodrop.rs
SimonSapin Jul 4, 2019
fc512d2
More descriptive variable name
SimonSapin Jul 4, 2019
616cf52
Extend union-nodrop.rs test
SimonSapin Jul 4, 2019
50ec10e
rpass tests are now part of `ui` tests
oli-obk Sep 20, 2019
9c1ad0f
Preserve originally intended test semantics
oli-obk Sep 20, 2019
2fc257c
Prefer `ManuallyDrop::{take,new}` over `ptr::{read,write}`
oli-obk Sep 20, 2019
fb23a5c
Clarify a vague comment
oli-obk Sep 20, 2019
7e1a65d
Ensure we do not treat all unions as not having any drop glue.
oli-obk Sep 20, 2019
f5669eb
Update ui stderr
oli-obk Sep 20, 2019
bb5a652
Rebase fallout
oli-obk Oct 17, 2019
5719f57
miri add write_bytes method to Memory doing bounds-checks and support…
RalfJung Oct 20, 2019
50ddcbb
also check the iterator is not too long
RalfJung Oct 20, 2019
77c50dc
Remove unnecessary trait bounds from `keys::Keys`.
nnethercote Oct 19, 2019
c3b3a86
Remove unnecessary `Hash` bounds from various types.
nnethercote Oct 19, 2019
0653694
Don't silently do nothing on mis_use of `check_union_fields`
oli-obk Oct 21, 2019
875bdd5
Report even duplilcate errors in case the feature gat is not active
oli-obk Oct 21, 2019
55b787e
keep the root dir clean from debugging
RalfJung Oct 21, 2019
d4b3654
points the user away from the Allocation type and towards the Memory …
RalfJung Oct 20, 2019
f6d70b4
remove write_repeat; it is subsumed by the new write_bytes
RalfJung Oct 21, 2019
ac6daed
Remove many unnecessary trait derivations.
nnethercote Oct 20, 2019
3de7698
Fix typo from #65214
Amanieu Oct 21, 2019
d689c70
improve readability of is_power_of_two
tspiteri Oct 21, 2019
ebc9a1a
expand comment
RalfJung Oct 21, 2019
e9c2685
Rename `ConstValue::Infer(InferConst::Canonical(..))` to `ConstValue:…
varkor Oct 21, 2019
aba8489
Rollup merge of #62330 - SimonSapin:no-drop-in-union-fields, r=RalfJung
Centril Oct 21, 2019
a160258
Rollup merge of #65092 - tspiteri:const-is-pow2, r=oli-obk
Centril Oct 21, 2019
e825e21
Rollup merge of #65621 - RalfJung:write_bytes, r=oli-obk
Centril Oct 21, 2019
9072e10
Rollup merge of #65647 - nnethercote:rm-unnecessary-traits, r=Centril
Centril Oct 21, 2019
760cd97
Rollup merge of #65653 - RalfJung:gitignore, r=Mark-Simulacrum,Centril
Centril Oct 21, 2019
c461d02
Rollup merge of #65660 - varkor:canonical-const-to-bound-const, r=eddyb
Centril Oct 21, 2019
56756c2
Rollup merge of #65663 - Amanieu:typo, r=varkor
Centril Oct 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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