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 4 pull requests #67987

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
90adafb
Distinguish between private items and hidden items in rustdoc
dtolnay Jan 4, 2020
c09e16d
Add `const_trait_impl` feature gate
ecstatic-morse Jan 2, 2020
664fe3a
Add `const_trait_bound_opt_out` feature gate
ecstatic-morse Jan 2, 2020
37259f8
Add a `constness` field to `ast::TraitRef`
ecstatic-morse Jan 2, 2020
0de1693
Parse `impl const Trait for Ty` syntax
ecstatic-morse Jan 2, 2020
14fca9f
Parse `?const Trait` bound syntax
ecstatic-morse Jan 2, 2020
0c62c67
Error when new syntax is lowered
ecstatic-morse Jan 3, 2020
45eb0f8
Reject `const` in inherent impls
ecstatic-morse Jan 4, 2020
5d43134
Check for `?const` in invalid contexts during AST validation
ecstatic-morse Jan 5, 2020
14c9ab8
Add tests for RFC 2632
ecstatic-morse Jan 3, 2020
eabd51a
Call all visit methods on trait definitions
ecstatic-morse Jan 5, 2020
76ce7a0
Add test for `?const` and `?` on the same bound
ecstatic-morse Jan 5, 2020
532fd39
Make `bound_context` more like neighboring functions
ecstatic-morse Jan 6, 2020
19f74cb
Add test for `?const` in nested impl/dyn trait
ecstatic-morse Jan 6, 2020
012127b
Remove weak.rs for VxWorks
Dec 9, 2019
7aa8ae0
Split `rustc_mir::{build, hair, lints}` into their own crate
matthewjasper Jan 5, 2020
cec957e
ignore signal SIGPIPE
BaoshanPang Dec 20, 2019
a7529f7
Rollup merge of #67820 - ecstatic-morse:const-trait, r=oli-obk
Centril Jan 7, 2020
4b9d279
Rollup merge of #67875 - dtolnay:hidden, r=GuillaumeGomez
Centril Jan 7, 2020
efce4ca
Rollup merge of #67901 - matthewjasper:split-mir-build, r=nagisa
Centril Jan 7, 2020
567e61d
Rollup merge of #67977 - Wind-River:master_2020, r=alexcrichton
Centril Jan 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3631,6 +3631,7 @@ dependencies = [
"rustc_lint",
"rustc_metadata",
"rustc_mir",
"rustc_mir_build",
"rustc_parse",
"rustc_passes",
"rustc_plugin_impl",
Expand Down Expand Up @@ -3729,7 +3730,6 @@ dependencies = [
name = "rustc_mir"
version = "0.0.0"
dependencies = [
"arena",
"either",
"graphviz",
"itertools 0.8.0",
Expand All @@ -3752,6 +3752,28 @@ dependencies = [
"syntax",
]

[[package]]
name = "rustc_mir_build"
version = "0.0.0"
dependencies = [
"arena",
"itertools 0.8.0",
"log",
"rustc",
"rustc_apfloat",
"rustc_data_structures",
"rustc_error_codes",
"rustc_errors",
"rustc_hir",
"rustc_index",
"rustc_macros",
"rustc_span",
"rustc_target",
"serialize",
"smallvec 1.0.0",
"syntax",
]

[[package]]
name = "rustc_msan"
version = "0.0.0"
Expand Down
223 changes: 4 additions & 219 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ use polonius_engine::Atom;
use rustc_data_structures::fx::FxHashSet;
use rustc_data_structures::graph::dominators::Dominators;
use rustc_data_structures::graph::{self, GraphSuccessors};
use rustc_data_structures::sync::Lrc;
use rustc_index::bit_set::BitMatrix;
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
use rustc_serialize::{Decodable, Encodable};
use rustc_span::symbol::Symbol;
use rustc_span::{Span, DUMMY_SP};
use smallvec::SmallVec;
use std::borrow::Cow;
use std::fmt::{self, Debug, Display, Formatter, Write};
use std::ops::Index;
Expand All @@ -39,13 +37,15 @@ use std::{iter, mem, option, u32};
pub use syntax::ast::Mutability;
use syntax::ast::Name;

pub use crate::mir::cache::{BodyAndCache, ReadOnlyBodyAndCache};
pub use crate::mir::interpret::AssertMessage;
pub use self::cache::{BodyAndCache, ReadOnlyBodyAndCache};
pub use self::interpret::AssertMessage;
pub use self::query::*;
pub use crate::read_only;

mod cache;
pub mod interpret;
pub mod mono;
mod query;
pub mod tcx;
pub mod traversal;
pub mod visit;
Expand Down Expand Up @@ -2648,221 +2648,6 @@ impl Location {
}
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
pub enum UnsafetyViolationKind {
General,
/// Permitted both in `const fn`s and regular `fn`s.
GeneralAndConstFn,
BorrowPacked(hir::HirId),
}

#[derive(Copy, Clone, PartialEq, RustcEncodable, RustcDecodable, HashStable)]
pub struct UnsafetyViolation {
pub source_info: SourceInfo,
pub description: Symbol,
pub details: Symbol,
pub kind: UnsafetyViolationKind,
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub struct UnsafetyCheckResult {
/// Violations that are propagated *upwards* from this function.
pub violations: Lrc<[UnsafetyViolation]>,
/// `unsafe` blocks in this function, along with whether they are used. This is
/// used for the "unused_unsafe" lint.
pub unsafe_blocks: Lrc<[(hir::HirId, bool)]>,
}

rustc_index::newtype_index! {
pub struct GeneratorSavedLocal {
derive [HashStable]
DEBUG_FORMAT = "_{}",
}
}

/// The layout of generator state.
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable, TypeFoldable)]
pub struct GeneratorLayout<'tcx> {
/// The type of every local stored inside the generator.
pub field_tys: IndexVec<GeneratorSavedLocal, Ty<'tcx>>,

/// Which of the above fields are in each variant. Note that one field may
/// be stored in multiple variants.
pub variant_fields: IndexVec<VariantIdx, IndexVec<Field, GeneratorSavedLocal>>,

/// Which saved locals are storage-live at the same time. Locals that do not
/// have conflicts with each other are allowed to overlap in the computed
/// layout.
pub storage_conflicts: BitMatrix<GeneratorSavedLocal, GeneratorSavedLocal>,
}

#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct BorrowCheckResult<'tcx> {
pub closure_requirements: Option<ClosureRegionRequirements<'tcx>>,
pub used_mut_upvars: SmallVec<[Field; 8]>,
}

/// The result of the `mir_const_qualif` query.
///
/// Each field corresponds to an implementer of the `Qualif` trait in
/// `librustc_mir/transform/check_consts/qualifs.rs`. See that file for more information on each
/// `Qualif`.
#[derive(Clone, Copy, Debug, Default, RustcEncodable, RustcDecodable, HashStable)]
pub struct ConstQualifs {
pub has_mut_interior: bool,
pub needs_drop: bool,
}

/// After we borrow check a closure, we are left with various
/// requirements that we have inferred between the free regions that
/// appear in the closure's signature or on its field types. These
/// requirements are then verified and proved by the closure's
/// creating function. This struct encodes those requirements.
///
/// The requirements are listed as being between various
/// `RegionVid`. The 0th region refers to `'static`; subsequent region
/// vids refer to the free regions that appear in the closure (or
/// generator's) type, in order of appearance. (This numbering is
/// actually defined by the `UniversalRegions` struct in the NLL
/// region checker. See for example
/// `UniversalRegions::closure_mapping`.) Note that we treat the free
/// regions in the closure's type "as if" they were erased, so their
/// precise identity is not important, only their position.
///
/// Example: If type check produces a closure with the closure substs:
///
/// ```text
/// ClosureSubsts = [
/// i8, // the "closure kind"
/// for<'x> fn(&'a &'x u32) -> &'x u32, // the "closure signature"
/// &'a String, // some upvar
/// ]
/// ```
///
/// here, there is one unique free region (`'a`) but it appears
/// twice. We would "renumber" each occurrence to a unique vid, as follows:
///
/// ```text
/// ClosureSubsts = [
/// i8, // the "closure kind"
/// for<'x> fn(&'1 &'x u32) -> &'x u32, // the "closure signature"
/// &'2 String, // some upvar
/// ]
/// ```
///
/// Now the code might impose a requirement like `'1: '2`. When an
/// instance of the closure is created, the corresponding free regions
/// can be extracted from its type and constrained to have the given
/// outlives relationship.
///
/// In some cases, we have to record outlives requirements between
/// types and regions as well. In that case, if those types include
/// any regions, those regions are recorded as `ReClosureBound`
/// instances assigned one of these same indices. Those regions will
/// be substituted away by the creator. We use `ReClosureBound` in
/// that case because the regions must be allocated in the global
/// `TyCtxt`, and hence we cannot use `ReVar` (which is what we use
/// internally within the rest of the NLL code).
#[derive(Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct ClosureRegionRequirements<'tcx> {
/// The number of external regions defined on the closure. In our
/// example above, it would be 3 -- one for `'static`, then `'1`
/// and `'2`. This is just used for a sanity check later on, to
/// make sure that the number of regions we see at the callsite
/// matches.
pub num_external_vids: usize,

/// Requirements between the various free regions defined in
/// indices.
pub outlives_requirements: Vec<ClosureOutlivesRequirement<'tcx>>,
}

/// Indicates an outlives-constraint between a type or between two
/// free regions declared on the closure.
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub struct ClosureOutlivesRequirement<'tcx> {
// This region or type ...
pub subject: ClosureOutlivesSubject<'tcx>,

// ... must outlive this one.
pub outlived_free_region: ty::RegionVid,

// If not, report an error here ...
pub blame_span: Span,

// ... due to this reason.
pub category: ConstraintCategory,
}

/// Outlives-constraints can be categorized to determine whether and why they
/// are interesting (for error reporting). Order of variants indicates sort
/// order of the category, thereby influencing diagnostic output.
///
/// See also [rustc_mir::borrow_check::nll::constraints].
#[derive(
Copy,
Clone,
Debug,
Eq,
PartialEq,
PartialOrd,
Ord,
Hash,
RustcEncodable,
RustcDecodable,
HashStable
)]
pub enum ConstraintCategory {
Return,
Yield,
UseAsConst,
UseAsStatic,
TypeAnnotation,
Cast,

/// A constraint that came from checking the body of a closure.
///
/// We try to get the category that the closure used when reporting this.
ClosureBounds,
CallArgument,
CopyBound,
SizedBound,
Assignment,
OpaqueType,

/// A "boring" constraint (caused by the given location) is one that
/// the user probably doesn't want to see described in diagnostics,
/// because it is kind of an artifact of the type system setup.
/// Example: `x = Foo { field: y }` technically creates
/// intermediate regions representing the "type of `Foo { field: y
/// }`", and data flows from `y` into those variables, but they
/// are not very interesting. The assignment into `x` on the other
/// hand might be.
Boring,
// Boring and applicable everywhere.
BoringNoLocation,

/// A constraint that doesn't correspond to anything the user sees.
Internal,
}

/// The subject of a `ClosureOutlivesRequirement` -- that is, the thing
/// that must outlive some region.
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
pub enum ClosureOutlivesSubject<'tcx> {
/// Subject is a type, typically a type parameter, but could also
/// be a projection. Indicates a requirement like `T: 'a` being
/// passed to the caller, where the type here is `T`.
///
/// The type here is guaranteed not to contain any free regions at
/// present.
Ty(Ty<'tcx>),

/// Subject is a free region from the closure. Indicates a requirement
/// like `'a: 'b` being passed to the caller; the region here is `'a`.
Region(ty::RegionVid),
}

/*
* `TypeFoldable` implementations for MIR types
*/
Expand Down
Loading