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 10 pull requests #54809

Merged
merged 23 commits into from
Oct 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fcda7b2
Add doc for impl From for Std Error
phungleson Sep 5, 2018
a7cc1fc
Examples for docs
phungleson Sep 25, 2018
ec59188
Make spec_extend use for_each()
Lucretiel Oct 2, 2018
84f75f0
Fix typo in CONTRIBUTING.md
Oct 2, 2018
30f2e96
Remove main() in examples
phungleson Oct 2, 2018
d686896
Update a FIXME in memory.rs
wesleywiser Oct 3, 2018
1081bbb
abolish ICE when pretty-printing async block
zackmdavis Oct 3, 2018
989f480
simplify some unused lints code
llogiq Oct 1, 2018
8327976
Remove duplicate predicates in `explicit_predicates_of`
scalexm Oct 3, 2018
f0de294
A handful of cleanups for rustc/mir
ljedrz Oct 3, 2018
608adfc
Introduce `TyKind::UnnormalizedProjection`
scalexm Oct 3, 2018
edb3f97
Fix `ty::UnnormalizedProjection` in rustdoc
scalexm Oct 3, 2018
b14dc69
remove padding from multiline format string label
euclio Oct 3, 2018
1dbc8b0
Rollup merge of #53523 - phungleson:fix-impl-from-for-std-error, r=Gu…
pietroalbini Oct 4, 2018
bc4f869
Rollup merge of #54746 - llogiq:simplify-unused-lints, r=michaelwoeri…
pietroalbini Oct 4, 2018
c215c19
Rollup merge of #54761 - Lucretiel:patch-1, r=cramertj
pietroalbini Oct 4, 2018
fdc1660
Rollup merge of #54769 - jacobherrington:patch-1, r=kennytm
pietroalbini Oct 4, 2018
2fda2f6
Rollup merge of #54773 - rust-lang:wesleywiser-patch-1, r=oli-obk
pietroalbini Oct 4, 2018
7523cdf
Rollup merge of #54777 - zackmdavis:async_pretty_ice, r=cramertj
pietroalbini Oct 4, 2018
cbc9477
Rollup merge of #54780 - scalexm:dup-predicates, r=nikomatsakis
pietroalbini Oct 4, 2018
bc2859d
Rollup merge of #54788 - ljedrz:cleanup_rustc_mir, r=oli-obk
pietroalbini Oct 4, 2018
2503db8
Rollup merge of #54789 - scalexm:unnormalized, r=nikomatsakis
pietroalbini Oct 4, 2018
71aded8
Rollup merge of #54795 - euclio:ifmt-bad-arg, r=estebank
pietroalbini Oct 4, 2018
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ labels to triage issues:
to fix the issue.

* The dark blue **final-comment-period** label marks bugs that are using the
RFC signoff functionality of [rfcbot][rfcbot] and are currenty in the final
RFC signoff functionality of [rfcbot][rfcbot] and are currently in the final
comment period.

* Red, **I**-prefixed labels indicate the **importance** of the issue. The
Expand Down
4 changes: 2 additions & 2 deletions src/liballoc/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1822,12 +1822,12 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
unsafe {
let mut ptr = self.as_mut_ptr().add(self.len());
let mut local_len = SetLenOnDrop::new(&mut self.len);
for element in iterator {
iterator.for_each(move |element| {
ptr::write(ptr, element);
ptr = ptr.offset(1);
// NB can't overflow since we would have had to alloc the address space
local_len.increment_len(1);
}
});
}
} else {
self.extend_desugared(iterator)
Expand Down
2 changes: 1 addition & 1 deletion src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ impl<'a> Parser<'a> {
self.cur.next();
Some(pos)
} else {
let pos = pos + padding + 1;
let pos = pos + raw + 1;
self.err(format!("expected `{:?}`, found `{:?}`", c, maybe),
format!("expected `{}`", c),
pos,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ich/impls_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ for ty::TyKind<'gcx>
Tuple(inner_tys) => {
inner_tys.hash_stable(hcx, hasher);
}
Projection(ref projection_ty) => {
projection_ty.hash_stable(hcx, hasher);
Projection(ref data) | UnnormalizedProjection(ref data) => {
data.hash_stable(hcx, hasher);
}
Opaque(def_id, substs) => {
def_id.hash_stable(hcx, hasher);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/infer/canonical/canonicalizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
| ty::Never
| ty::Tuple(..)
| ty::Projection(..)
| ty::UnnormalizedProjection(..)
| ty::Foreign(..)
| ty::Param(..)
| ty::Opaque(..) => {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/infer/freshen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
ty::Never |
ty::Tuple(..) |
ty::Projection(..) |
ty::UnnormalizedProjection(..) |
ty::Foreign(..) |
ty::Param(..) |
ty::Closure(..) |
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl<'tcx> Scalar {
pub fn from_uint(i: impl Into<u128>, size: Size) -> Self {
let i = i.into();
debug_assert_eq!(truncate(i, size), i,
"Unsigned value {} does not fit in {} bits", i, size.bits());
"Unsigned value {} does not fit in {} bits", i, size.bits());
Scalar::Bits { bits: i, size: size.bytes() as u8 }
}

Expand All @@ -181,7 +181,7 @@ impl<'tcx> Scalar {
// `into` performed sign extension, we have to truncate
let truncated = truncate(i as u128, size);
debug_assert_eq!(sign_extend(truncated, size) as i128, i,
"Signed value {} does not fit in {} bits", i, size.bits());
"Signed value {} does not fit in {} bits", i, size.bits());
Scalar::Bits { bits: truncated, size: size.bytes() as u8 }
}

Expand Down
31 changes: 13 additions & 18 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
//!
//! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/mir/index.html

use graphviz::IntoCow;
use hir::def::CtorKind;
use hir::def_id::DefId;
use hir::{self, HirId, InlineAsm};
Expand Down Expand Up @@ -327,22 +326,20 @@ impl<'tcx> Mir<'tcx> {
if idx < stmts.len() {
&stmts[idx].source_info
} else {
assert!(idx == stmts.len());
assert_eq!(idx, stmts.len());
&block.terminator().source_info
}
}

/// Check if `sub` is a sub scope of `sup`
pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
loop {
if sub == sup {
return true;
}
while sub != sup {
match self.source_scopes[sub].parent_scope {
None => return false,
Some(p) => sub = p,
}
}
true
}

/// Return the return type, it always return first element from `local_decls` array
Expand Down Expand Up @@ -526,9 +523,7 @@ impl BorrowKind {
pub fn allows_two_phase_borrow(&self) -> bool {
match *self {
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => false,
BorrowKind::Mut {
allow_two_phase_borrow,
} => allow_two_phase_borrow,
BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow,
}
}
}
Expand Down Expand Up @@ -1574,42 +1569,42 @@ impl<'tcx> TerminatorKind<'tcx> {
};
fmt_const_val(&mut s, &c).unwrap();
s.into()
}).chain(iter::once(String::from("otherwise").into()))
}).chain(iter::once("otherwise".into()))
.collect()
}
Call {
destination: Some(_),
cleanup: Some(_),
..
} => vec!["return".into_cow(), "unwind".into_cow()],
} => vec!["return".into(), "unwind".into()],
Call {
destination: Some(_),
cleanup: None,
..
} => vec!["return".into_cow()],
} => vec!["return".into()],
Call {
destination: None,
cleanup: Some(_),
..
} => vec!["unwind".into_cow()],
} => vec!["unwind".into()],
Call {
destination: None,
cleanup: None,
..
} => vec![],
Yield { drop: Some(_), .. } => vec!["resume".into_cow(), "drop".into_cow()],
Yield { drop: None, .. } => vec!["resume".into_cow()],
Yield { drop: Some(_), .. } => vec!["resume".into(), "drop".into()],
Yield { drop: None, .. } => vec!["resume".into()],
DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => {
vec!["return".into_cow()]
vec!["return".into()]
}
DropAndReplace {
unwind: Some(_), ..
}
| Drop {
unwind: Some(_), ..
} => vec!["return".into_cow(), "unwind".into_cow()],
} => vec!["return".into(), "unwind".into()],
Assert { cleanup: None, .. } => vec!["".into()],
Assert { .. } => vec!["success".into_cow(), "unwind".into_cow()],
Assert { .. } => vec!["success".into(), "unwind".into()],
FalseEdges {
ref imaginary_targets,
..
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/mono.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> {
String::new()
};

let crate_disambiguator = format!("{}", tcx.crate_disambiguator(cnum));
let crate_disambiguator = tcx.crate_disambiguator(cnum).to_string();
// Using a shortened disambiguator of about 40 bits
format!("{}.{}{}",
tcx.crate_name(cnum),
Expand Down
12 changes: 6 additions & 6 deletions src/librustc/mir/tcx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
assert!(index < adt_def.variants.len());
assert_eq!(adt_def, adt_def1);
PlaceTy::Downcast { adt_def,
substs,
variant_index: index }
substs,
variant_index: index }
}
_ => {
bug!("cannot downcast non-ADT type: `{:?}`", self)
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<'tcx> Place<'tcx> {
}
},
_ => None,
}
}
_ => None,
}
}
Expand Down Expand Up @@ -255,9 +255,9 @@ impl<'tcx> Operand<'tcx> {

impl<'tcx> BinOp {
pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>)
-> Ty<'tcx> {
lhs_ty: Ty<'tcx>,
rhs_ty: Ty<'tcx>)
-> Ty<'tcx> {
// FIXME: handle SIMD correctly
match self {
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |
Expand Down
1 change: 1 addition & 0 deletions src/librustc/traits/coherence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool {

ty::Error => true,

ty::UnnormalizedProjection(..) |
ty::Closure(..) |
ty::Generator(..) |
ty::GeneratorWitness(..) |
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
ty::Generator(..) => Some(18),
ty::Foreign(..) => Some(19),
ty::GeneratorWitness(..) => Some(20),
ty::Infer(..) | ty::Error => None
ty::Infer(..) | ty::Error => None,
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/librustc/traits/query/dropck_outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
| ty::Opaque(..)
| ty::Infer(_)
| ty::Generator(..) => false,

ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
}
}
3 changes: 3 additions & 0 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2283,6 +2283,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None,
ty::Infer(ty::TyVar(_)) => Ambiguous,

ty::UnnormalizedProjection(..) |
ty::Infer(ty::CanonicalTy(_)) |
ty::Infer(ty::FreshTy(_)) |
ty::Infer(ty::FreshIntTy(_)) |
Expand Down Expand Up @@ -2355,6 +2356,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
Ambiguous
}

ty::UnnormalizedProjection(..) |
ty::Infer(ty::CanonicalTy(_)) |
ty::Infer(ty::FreshTy(_)) |
ty::Infer(ty::FreshIntTy(_)) |
Expand Down Expand Up @@ -2393,6 +2395,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
Vec::new()
}

ty::UnnormalizedProjection(..) |
ty::Dynamic(..) |
ty::Param(..) |
ty::Foreign(..) |
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
self,
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
Param, Infer, Projection, Opaque, Foreign);
Param, Infer, UnnormalizedProjection, Projection, Opaque, Foreign);

println!("Substs interner: #{}", self.interners.substs.borrow().len());
println!("Region interner: #{}", self.interners.region.borrow().len());
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
ty::Projection(_) => "associated type".to_string(),
ty::UnnormalizedProjection(_) => "non-normalized associated type".to_string(),
ty::Param(ref p) => {
if p.is_self() {
"Self".to_string()
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/fast_reject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
ty::FnPtr(ref f) => {
Some(FunctionSimplifiedType(f.skip_binder().inputs().len()))
}
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
ty::Projection(_) | ty::Param(_) => {
if can_simplify_params {
// In normalized types, projections don't unify with
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ impl FlagComputation {
self.add_projection_ty(data);
}

&ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

&ty::Opaque(_, substs) => {
self.add_flags(TypeFlags::HAS_PROJECTION);
self.add_substs(substs);
Expand Down
1 change: 1 addition & 0 deletions src/librustc/ty/item_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
ty::Str |
ty::FnPtr(_) |
ty::Projection(_) |
ty::UnnormalizedProjection(..) |
ty::Param(_) |
ty::Opaque(..) |
ty::Infer(_) |
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
}
tcx.layout_raw(param_env.and(normalized))?
}
ty::GeneratorWitness(..) | ty::Infer(_) => {
ty::UnnormalizedProjection(..) | ty::GeneratorWitness(..) | ty::Infer(_) => {
bug!("LayoutDetails::compute: unexpected type `{}`", ty)
}
ty::Param(_) | ty::Error => {
Expand Down Expand Up @@ -1702,8 +1702,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
}
}

ty::Projection(_) | ty::Opaque(..) | ty::Param(_) |
ty::Infer(_) | ty::Error => {
ty::Projection(_) | ty::UnnormalizedProjection(..) |
ty::Opaque(..) | ty::Param(_) | ty::Infer(_) | ty::Error => {
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
}
})
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2340,6 +2340,8 @@ impl<'a, 'gcx, 'tcx> AdtDef {
vec![ty]
}

UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

Param(..) => {
// perf hack: if there is a `T: Sized` bound, then
// we know that `T` is Sized and do not need to check
Expand Down
2 changes: 2 additions & 0 deletions src/librustc/ty/outlives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}
}

ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

// We assume that inference variables are fully resolved.
// So, if we encounter an inference variable, just record
// the unresolved variable as a component.
Expand Down
7 changes: 6 additions & 1 deletion src/librustc/ty/structural_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
ty::Closure(did, substs) => ty::Closure(did, substs.fold_with(folder)),
ty::Projection(ref data) => ty::Projection(data.fold_with(folder)),
ty::UnnormalizedProjection(ref data) => {
ty::UnnormalizedProjection(data.fold_with(folder))
}
ty::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
Expand Down Expand Up @@ -910,7 +913,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
}
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
ty::Closure(_did, ref substs) => substs.visit_with(visitor),
ty::Projection(ref data) => data.visit_with(visitor),
ty::Projection(ref data) | ty::UnnormalizedProjection(ref data) => {
data.visit_with(visitor)
}
ty::Opaque(_, ref substs) => substs.visit_with(visitor),
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
Expand Down
9 changes: 8 additions & 1 deletion src/librustc/ty/sty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@ pub enum TyKind<'tcx> {
/// `<T as Trait<..>>::N`.
Projection(ProjectionTy<'tcx>),

/// A placeholder type used when we do not have enough information
/// to normalize the projection of an associated type to an
/// existing concrete type. Currently only used with chalk-engine.
UnnormalizedProjection(ProjectionTy<'tcx>),

/// Opaque (`impl Trait`) type found in a return type.
/// The `DefId` comes either from
/// * the `impl Trait` ast::Ty node,
Expand Down Expand Up @@ -1806,7 +1811,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
Generator(_, GeneratorSubsts { ref substs }, _) => {
substs.regions().collect()
}
Projection(ref data) => {
Projection(ref data) | UnnormalizedProjection(ref data) => {
data.substs.regions().collect()
}
FnDef(..) |
Expand Down Expand Up @@ -1886,6 +1891,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {

ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,

ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),

ty::Infer(ty::TyVar(_)) => false,

ty::Infer(ty::CanonicalTy(_)) |
Expand Down
Loading