mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-28 11:07:42 +00:00
Auto merge of #54809 - pietroalbini:rollup, r=pietroalbini
Rollup of 10 pull requests Successful merges: - #53523 (Add doc for impl From for Std Error) - #54746 (simplify some unused lints code) - #54761 (Make spec_extend use for_each()) - #54769 (Fix typo in CONTRIBUTING.md) - #54773 (Update a FIXME in memory.rs) - #54777 (abolish ICE when pretty-printing async block) - #54780 (Remove duplicate predicates in `explicit_predicates_of`) - #54788 (A handful of cleanups for rustc/mir) - #54789 (Introduce `TyKind::UnnormalizedProjection`) - #54795 (remove padding from multiline format string label) Failed merges: r? @ghost
This commit is contained in:
commit
5472b0718f
@ -566,7 +566,7 @@ labels to triage issues:
|
|||||||
to fix the issue.
|
to fix the issue.
|
||||||
|
|
||||||
* The dark blue **final-comment-period** label marks bugs that are using the
|
* 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.
|
comment period.
|
||||||
|
|
||||||
* Red, **I**-prefixed labels indicate the **importance** of the issue. The
|
* Red, **I**-prefixed labels indicate the **importance** of the issue. The
|
||||||
|
@ -1822,12 +1822,12 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
|
|||||||
unsafe {
|
unsafe {
|
||||||
let mut ptr = self.as_mut_ptr().add(self.len());
|
let mut ptr = self.as_mut_ptr().add(self.len());
|
||||||
let mut local_len = SetLenOnDrop::new(&mut 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::write(ptr, element);
|
||||||
ptr = ptr.offset(1);
|
ptr = ptr.offset(1);
|
||||||
// NB can't overflow since we would have had to alloc the address space
|
// NB can't overflow since we would have had to alloc the address space
|
||||||
local_len.increment_len(1);
|
local_len.increment_len(1);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
self.extend_desugared(iterator)
|
self.extend_desugared(iterator)
|
||||||
|
@ -288,7 +288,7 @@ impl<'a> Parser<'a> {
|
|||||||
self.cur.next();
|
self.cur.next();
|
||||||
Some(pos)
|
Some(pos)
|
||||||
} else {
|
} else {
|
||||||
let pos = pos + padding + 1;
|
let pos = pos + raw + 1;
|
||||||
self.err(format!("expected `{:?}`, found `{:?}`", c, maybe),
|
self.err(format!("expected `{:?}`, found `{:?}`", c, maybe),
|
||||||
format!("expected `{}`", c),
|
format!("expected `{}`", c),
|
||||||
pos,
|
pos,
|
||||||
|
@ -873,8 +873,8 @@ for ty::TyKind<'gcx>
|
|||||||
Tuple(inner_tys) => {
|
Tuple(inner_tys) => {
|
||||||
inner_tys.hash_stable(hcx, hasher);
|
inner_tys.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
Projection(ref projection_ty) => {
|
Projection(ref data) | UnnormalizedProjection(ref data) => {
|
||||||
projection_ty.hash_stable(hcx, hasher);
|
data.hash_stable(hcx, hasher);
|
||||||
}
|
}
|
||||||
Opaque(def_id, substs) => {
|
Opaque(def_id, substs) => {
|
||||||
def_id.hash_stable(hcx, hasher);
|
def_id.hash_stable(hcx, hasher);
|
||||||
|
@ -283,6 +283,7 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for Canonicalizer<'cx, 'gcx, 'tcx>
|
|||||||
| ty::Never
|
| ty::Never
|
||||||
| ty::Tuple(..)
|
| ty::Tuple(..)
|
||||||
| ty::Projection(..)
|
| ty::Projection(..)
|
||||||
|
| ty::UnnormalizedProjection(..)
|
||||||
| ty::Foreign(..)
|
| ty::Foreign(..)
|
||||||
| ty::Param(..)
|
| ty::Param(..)
|
||||||
| ty::Opaque(..) => {
|
| ty::Opaque(..) => {
|
||||||
|
@ -193,6 +193,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> {
|
|||||||
ty::Never |
|
ty::Never |
|
||||||
ty::Tuple(..) |
|
ty::Tuple(..) |
|
||||||
ty::Projection(..) |
|
ty::Projection(..) |
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Foreign(..) |
|
ty::Foreign(..) |
|
||||||
ty::Param(..) |
|
ty::Param(..) |
|
||||||
ty::Closure(..) |
|
ty::Closure(..) |
|
||||||
|
@ -171,7 +171,7 @@ impl<'tcx> Scalar {
|
|||||||
pub fn from_uint(i: impl Into<u128>, size: Size) -> Self {
|
pub fn from_uint(i: impl Into<u128>, size: Size) -> Self {
|
||||||
let i = i.into();
|
let i = i.into();
|
||||||
debug_assert_eq!(truncate(i, size), i,
|
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 }
|
Scalar::Bits { bits: i, size: size.bytes() as u8 }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,7 +181,7 @@ impl<'tcx> Scalar {
|
|||||||
// `into` performed sign extension, we have to truncate
|
// `into` performed sign extension, we have to truncate
|
||||||
let truncated = truncate(i as u128, size);
|
let truncated = truncate(i as u128, size);
|
||||||
debug_assert_eq!(sign_extend(truncated, size) as i128, i,
|
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 }
|
Scalar::Bits { bits: truncated, size: size.bytes() as u8 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
//!
|
//!
|
||||||
//! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/mir/index.html
|
//! [rustc guide]: https://rust-lang-nursery.github.io/rustc-guide/mir/index.html
|
||||||
|
|
||||||
use graphviz::IntoCow;
|
|
||||||
use hir::def::CtorKind;
|
use hir::def::CtorKind;
|
||||||
use hir::def_id::DefId;
|
use hir::def_id::DefId;
|
||||||
use hir::{self, HirId, InlineAsm};
|
use hir::{self, HirId, InlineAsm};
|
||||||
@ -327,22 +326,20 @@ impl<'tcx> Mir<'tcx> {
|
|||||||
if idx < stmts.len() {
|
if idx < stmts.len() {
|
||||||
&stmts[idx].source_info
|
&stmts[idx].source_info
|
||||||
} else {
|
} else {
|
||||||
assert!(idx == stmts.len());
|
assert_eq!(idx, stmts.len());
|
||||||
&block.terminator().source_info
|
&block.terminator().source_info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if `sub` is a sub scope of `sup`
|
/// Check if `sub` is a sub scope of `sup`
|
||||||
pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
|
pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
|
||||||
loop {
|
while sub != sup {
|
||||||
if sub == sup {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
match self.source_scopes[sub].parent_scope {
|
match self.source_scopes[sub].parent_scope {
|
||||||
None => return false,
|
None => return false,
|
||||||
Some(p) => sub = p,
|
Some(p) => sub = p,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the return type, it always return first element from `local_decls` array
|
/// Return the return type, it always return first element from `local_decls` array
|
||||||
@ -526,9 +523,7 @@ impl BorrowKind {
|
|||||||
pub fn allows_two_phase_borrow(&self) -> bool {
|
pub fn allows_two_phase_borrow(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => false,
|
BorrowKind::Shared | BorrowKind::Shallow | BorrowKind::Unique => false,
|
||||||
BorrowKind::Mut {
|
BorrowKind::Mut { allow_two_phase_borrow } => allow_two_phase_borrow,
|
||||||
allow_two_phase_borrow,
|
|
||||||
} => allow_two_phase_borrow,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1574,42 +1569,42 @@ impl<'tcx> TerminatorKind<'tcx> {
|
|||||||
};
|
};
|
||||||
fmt_const_val(&mut s, &c).unwrap();
|
fmt_const_val(&mut s, &c).unwrap();
|
||||||
s.into()
|
s.into()
|
||||||
}).chain(iter::once(String::from("otherwise").into()))
|
}).chain(iter::once("otherwise".into()))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
Call {
|
Call {
|
||||||
destination: Some(_),
|
destination: Some(_),
|
||||||
cleanup: Some(_),
|
cleanup: Some(_),
|
||||||
..
|
..
|
||||||
} => vec!["return".into_cow(), "unwind".into_cow()],
|
} => vec!["return".into(), "unwind".into()],
|
||||||
Call {
|
Call {
|
||||||
destination: Some(_),
|
destination: Some(_),
|
||||||
cleanup: None,
|
cleanup: None,
|
||||||
..
|
..
|
||||||
} => vec!["return".into_cow()],
|
} => vec!["return".into()],
|
||||||
Call {
|
Call {
|
||||||
destination: None,
|
destination: None,
|
||||||
cleanup: Some(_),
|
cleanup: Some(_),
|
||||||
..
|
..
|
||||||
} => vec!["unwind".into_cow()],
|
} => vec!["unwind".into()],
|
||||||
Call {
|
Call {
|
||||||
destination: None,
|
destination: None,
|
||||||
cleanup: None,
|
cleanup: None,
|
||||||
..
|
..
|
||||||
} => vec![],
|
} => vec![],
|
||||||
Yield { drop: Some(_), .. } => vec!["resume".into_cow(), "drop".into_cow()],
|
Yield { drop: Some(_), .. } => vec!["resume".into(), "drop".into()],
|
||||||
Yield { drop: None, .. } => vec!["resume".into_cow()],
|
Yield { drop: None, .. } => vec!["resume".into()],
|
||||||
DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => {
|
DropAndReplace { unwind: None, .. } | Drop { unwind: None, .. } => {
|
||||||
vec!["return".into_cow()]
|
vec!["return".into()]
|
||||||
}
|
}
|
||||||
DropAndReplace {
|
DropAndReplace {
|
||||||
unwind: Some(_), ..
|
unwind: Some(_), ..
|
||||||
}
|
}
|
||||||
| Drop {
|
| Drop {
|
||||||
unwind: Some(_), ..
|
unwind: Some(_), ..
|
||||||
} => vec!["return".into_cow(), "unwind".into_cow()],
|
} => vec!["return".into(), "unwind".into()],
|
||||||
Assert { cleanup: None, .. } => vec!["".into()],
|
Assert { cleanup: None, .. } => vec!["".into()],
|
||||||
Assert { .. } => vec!["success".into_cow(), "unwind".into_cow()],
|
Assert { .. } => vec!["success".into(), "unwind".into()],
|
||||||
FalseEdges {
|
FalseEdges {
|
||||||
ref imaginary_targets,
|
ref imaginary_targets,
|
||||||
..
|
..
|
||||||
|
@ -325,7 +325,7 @@ impl<'a, 'gcx: 'tcx, 'tcx: 'a> CodegenUnitNameBuilder<'a, 'gcx, 'tcx> {
|
|||||||
String::new()
|
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
|
// Using a shortened disambiguator of about 40 bits
|
||||||
format!("{}.{}{}",
|
format!("{}.{}{}",
|
||||||
tcx.crate_name(cnum),
|
tcx.crate_name(cnum),
|
||||||
|
@ -87,8 +87,8 @@ impl<'a, 'gcx, 'tcx> PlaceTy<'tcx> {
|
|||||||
assert!(index < adt_def.variants.len());
|
assert!(index < adt_def.variants.len());
|
||||||
assert_eq!(adt_def, adt_def1);
|
assert_eq!(adt_def, adt_def1);
|
||||||
PlaceTy::Downcast { adt_def,
|
PlaceTy::Downcast { adt_def,
|
||||||
substs,
|
substs,
|
||||||
variant_index: index }
|
variant_index: index }
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
bug!("cannot downcast non-ADT type: `{:?}`", self)
|
bug!("cannot downcast non-ADT type: `{:?}`", self)
|
||||||
@ -151,7 +151,7 @@ impl<'tcx> Place<'tcx> {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -255,9 +255,9 @@ impl<'tcx> Operand<'tcx> {
|
|||||||
|
|
||||||
impl<'tcx> BinOp {
|
impl<'tcx> BinOp {
|
||||||
pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
pub fn ty<'a, 'gcx>(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||||
lhs_ty: Ty<'tcx>,
|
lhs_ty: Ty<'tcx>,
|
||||||
rhs_ty: Ty<'tcx>)
|
rhs_ty: Ty<'tcx>)
|
||||||
-> Ty<'tcx> {
|
-> Ty<'tcx> {
|
||||||
// FIXME: handle SIMD correctly
|
// FIXME: handle SIMD correctly
|
||||||
match self {
|
match self {
|
||||||
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |
|
&BinOp::Add | &BinOp::Sub | &BinOp::Mul | &BinOp::Div | &BinOp::Rem |
|
||||||
|
@ -475,6 +475,7 @@ fn ty_is_local_constructor(ty: Ty<'_>, in_crate: InCrate) -> bool {
|
|||||||
|
|
||||||
ty::Error => true,
|
ty::Error => true,
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Closure(..) |
|
ty::Closure(..) |
|
||||||
ty::Generator(..) |
|
ty::Generator(..) |
|
||||||
ty::GeneratorWitness(..) |
|
ty::GeneratorWitness(..) |
|
||||||
|
@ -269,7 +269,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
|
|||||||
ty::Generator(..) => Some(18),
|
ty::Generator(..) => Some(18),
|
||||||
ty::Foreign(..) => Some(19),
|
ty::Foreign(..) => Some(19),
|
||||||
ty::GeneratorWitness(..) => Some(20),
|
ty::GeneratorWitness(..) => Some(20),
|
||||||
ty::Infer(..) | ty::Error => None
|
ty::Infer(..) | ty::Error => None,
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,5 +253,7 @@ pub fn trivial_dropck_outlives<'tcx>(tcx: TyCtxt<'_, '_, 'tcx>, ty: Ty<'tcx>) ->
|
|||||||
| ty::Opaque(..)
|
| ty::Opaque(..)
|
||||||
| ty::Infer(_)
|
| ty::Infer(_)
|
||||||
| ty::Generator(..) => false,
|
| ty::Generator(..) => false,
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2283,6 +2283,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||||||
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None,
|
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None,
|
||||||
ty::Infer(ty::TyVar(_)) => Ambiguous,
|
ty::Infer(ty::TyVar(_)) => Ambiguous,
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Infer(ty::CanonicalTy(_)) |
|
ty::Infer(ty::CanonicalTy(_)) |
|
||||||
ty::Infer(ty::FreshTy(_)) |
|
ty::Infer(ty::FreshTy(_)) |
|
||||||
ty::Infer(ty::FreshIntTy(_)) |
|
ty::Infer(ty::FreshIntTy(_)) |
|
||||||
@ -2355,6 +2356,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||||||
Ambiguous
|
Ambiguous
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Infer(ty::CanonicalTy(_)) |
|
ty::Infer(ty::CanonicalTy(_)) |
|
||||||
ty::Infer(ty::FreshTy(_)) |
|
ty::Infer(ty::FreshTy(_)) |
|
||||||
ty::Infer(ty::FreshIntTy(_)) |
|
ty::Infer(ty::FreshIntTy(_)) |
|
||||||
@ -2393,6 +2395,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
|
|||||||
Vec::new()
|
Vec::new()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Dynamic(..) |
|
ty::Dynamic(..) |
|
||||||
ty::Param(..) |
|
ty::Param(..) |
|
||||||
ty::Foreign(..) |
|
ty::Foreign(..) |
|
||||||
|
@ -2234,7 +2234,7 @@ impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
|
|||||||
self,
|
self,
|
||||||
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
|
Adt, Array, Slice, RawPtr, Ref, FnDef, FnPtr,
|
||||||
Generator, GeneratorWitness, Dynamic, Closure, Tuple,
|
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!("Substs interner: #{}", self.interners.substs.borrow().len());
|
||||||
println!("Region interner: #{}", self.interners.region.borrow().len());
|
println!("Region interner: #{}", self.interners.region.borrow().len());
|
||||||
|
@ -222,6 +222,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> {
|
|||||||
ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
|
ty::Infer(ty::FreshIntTy(_)) => "skolemized integral type".to_string(),
|
||||||
ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
|
ty::Infer(ty::FreshFloatTy(_)) => "skolemized floating-point type".to_string(),
|
||||||
ty::Projection(_) => "associated type".to_string(),
|
ty::Projection(_) => "associated type".to_string(),
|
||||||
|
ty::UnnormalizedProjection(_) => "non-normalized associated type".to_string(),
|
||||||
ty::Param(ref p) => {
|
ty::Param(ref p) => {
|
||||||
if p.is_self() {
|
if p.is_self() {
|
||||||
"Self".to_string()
|
"Self".to_string()
|
||||||
|
@ -103,6 +103,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
|||||||
ty::FnPtr(ref f) => {
|
ty::FnPtr(ref f) => {
|
||||||
Some(FunctionSimplifiedType(f.skip_binder().inputs().len()))
|
Some(FunctionSimplifiedType(f.skip_binder().inputs().len()))
|
||||||
}
|
}
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
ty::Projection(_) | ty::Param(_) => {
|
ty::Projection(_) | ty::Param(_) => {
|
||||||
if can_simplify_params {
|
if can_simplify_params {
|
||||||
// In normalized types, projections don't unify with
|
// In normalized types, projections don't unify with
|
||||||
|
@ -150,6 +150,8 @@ impl FlagComputation {
|
|||||||
self.add_projection_ty(data);
|
self.add_projection_ty(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
&ty::Opaque(_, substs) => {
|
&ty::Opaque(_, substs) => {
|
||||||
self.add_flags(TypeFlags::HAS_PROJECTION);
|
self.add_flags(TypeFlags::HAS_PROJECTION);
|
||||||
self.add_substs(substs);
|
self.add_substs(substs);
|
||||||
|
@ -463,6 +463,7 @@ pub fn characteristic_def_id_of_type(ty: Ty<'_>) -> Option<DefId> {
|
|||||||
ty::Str |
|
ty::Str |
|
||||||
ty::FnPtr(_) |
|
ty::FnPtr(_) |
|
||||||
ty::Projection(_) |
|
ty::Projection(_) |
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Param(_) |
|
ty::Param(_) |
|
||||||
ty::Opaque(..) |
|
ty::Opaque(..) |
|
||||||
ty::Infer(_) |
|
ty::Infer(_) |
|
||||||
|
@ -1123,7 +1123,7 @@ impl<'a, 'tcx> LayoutCx<'tcx, TyCtxt<'a, 'tcx, 'tcx>> {
|
|||||||
}
|
}
|
||||||
tcx.layout_raw(param_env.and(normalized))?
|
tcx.layout_raw(param_env.and(normalized))?
|
||||||
}
|
}
|
||||||
ty::GeneratorWitness(..) | ty::Infer(_) => {
|
ty::UnnormalizedProjection(..) | ty::GeneratorWitness(..) | ty::Infer(_) => {
|
||||||
bug!("LayoutDetails::compute: unexpected type `{}`", ty)
|
bug!("LayoutDetails::compute: unexpected type `{}`", ty)
|
||||||
}
|
}
|
||||||
ty::Param(_) | ty::Error => {
|
ty::Param(_) | ty::Error => {
|
||||||
@ -1702,8 +1702,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ty::Projection(_) | ty::Opaque(..) | ty::Param(_) |
|
ty::Projection(_) | ty::UnnormalizedProjection(..) |
|
||||||
ty::Infer(_) | ty::Error => {
|
ty::Opaque(..) | ty::Param(_) | ty::Infer(_) | ty::Error => {
|
||||||
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
|
bug!("TyLayout::field_type: unexpected type `{}`", this.ty)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -2340,6 +2340,8 @@ impl<'a, 'gcx, 'tcx> AdtDef {
|
|||||||
vec![ty]
|
vec![ty]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
Param(..) => {
|
Param(..) => {
|
||||||
// perf hack: if there is a `T: Sized` bound, then
|
// perf hack: if there is a `T: Sized` bound, then
|
||||||
// we know that `T` is Sized and do not need to check
|
// we know that `T` is Sized and do not need to check
|
||||||
|
@ -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.
|
// We assume that inference variables are fully resolved.
|
||||||
// So, if we encounter an inference variable, just record
|
// So, if we encounter an inference variable, just record
|
||||||
// the unresolved variable as a component.
|
// the unresolved variable as a component.
|
||||||
|
@ -876,6 +876,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||||||
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
|
ty::GeneratorWitness(types) => ty::GeneratorWitness(types.fold_with(folder)),
|
||||||
ty::Closure(did, substs) => ty::Closure(did, substs.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::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::Opaque(did, substs) => ty::Opaque(did, substs.fold_with(folder)),
|
||||||
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
||||||
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
||||||
@ -910,7 +913,9 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> {
|
|||||||
}
|
}
|
||||||
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
ty::GeneratorWitness(ref types) => types.visit_with(visitor),
|
||||||
ty::Closure(_did, ref substs) => substs.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::Opaque(_, ref substs) => substs.visit_with(visitor),
|
||||||
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
ty::Bool | ty::Char | ty::Str | ty::Int(_) |
|
||||||
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
ty::Uint(_) | ty::Float(_) | ty::Error | ty::Infer(_) |
|
||||||
|
@ -157,6 +157,11 @@ pub enum TyKind<'tcx> {
|
|||||||
/// `<T as Trait<..>>::N`.
|
/// `<T as Trait<..>>::N`.
|
||||||
Projection(ProjectionTy<'tcx>),
|
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.
|
/// Opaque (`impl Trait`) type found in a return type.
|
||||||
/// The `DefId` comes either from
|
/// The `DefId` comes either from
|
||||||
/// * the `impl Trait` ast::Ty node,
|
/// * the `impl Trait` ast::Ty node,
|
||||||
@ -1806,7 +1811,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
Generator(_, GeneratorSubsts { ref substs }, _) => {
|
Generator(_, GeneratorSubsts { ref substs }, _) => {
|
||||||
substs.regions().collect()
|
substs.regions().collect()
|
||||||
}
|
}
|
||||||
Projection(ref data) => {
|
Projection(ref data) | UnnormalizedProjection(ref data) => {
|
||||||
data.substs.regions().collect()
|
data.substs.regions().collect()
|
||||||
}
|
}
|
||||||
FnDef(..) |
|
FnDef(..) |
|
||||||
@ -1886,6 +1891,8 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
|||||||
|
|
||||||
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,
|
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => false,
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
ty::Infer(ty::TyVar(_)) => false,
|
ty::Infer(ty::TyVar(_)) => false,
|
||||||
|
|
||||||
ty::Infer(ty::CanonicalTy(_)) |
|
ty::Infer(ty::CanonicalTy(_)) |
|
||||||
|
@ -958,6 +958,8 @@ fn needs_drop_raw<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
|||||||
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) |
|
ty::Dynamic(..) | ty::Projection(..) | ty::Param(_) |
|
||||||
ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
|
ty::Opaque(..) | ty::Infer(_) | ty::Error => true,
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
// Structural recursion.
|
// Structural recursion.
|
||||||
ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),
|
ty::Array(ty, _) | ty::Slice(ty) => needs_drop(ty),
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ fn push_subtypes<'tcx>(stack: &mut TypeWalkerStack<'tcx>, parent_ty: Ty<'tcx>) {
|
|||||||
ty::Ref(_, ty, _) => {
|
ty::Ref(_, ty, _) => {
|
||||||
stack.push(ty);
|
stack.push(ty);
|
||||||
}
|
}
|
||||||
ty::Projection(ref data) => {
|
ty::Projection(ref data) | ty::UnnormalizedProjection(ref data) => {
|
||||||
stack.extend(data.substs.types().rev());
|
stack.extend(data.substs.types().rev());
|
||||||
}
|
}
|
||||||
ty::Dynamic(ref obj, ..) => {
|
ty::Dynamic(ref obj, ..) => {
|
||||||
|
@ -289,6 +289,8 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> {
|
|||||||
self.compute_projection(data);
|
self.compute_projection(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
ty::Adt(def, substs) => {
|
ty::Adt(def, substs) => {
|
||||||
// WfNominalType
|
// WfNominalType
|
||||||
let obligations = self.nominal_obligations(def.did, substs);
|
let obligations = self.nominal_obligations(def.did, substs);
|
||||||
|
@ -18,7 +18,7 @@ use ty::{Bool, Char, Adt};
|
|||||||
use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
|
use ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
|
||||||
use ty::{Param, RawPtr, Ref, Never, Tuple};
|
use ty::{Param, RawPtr, Ref, Never, Tuple};
|
||||||
use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque};
|
use ty::{Closure, Generator, GeneratorWitness, Foreign, Projection, Opaque};
|
||||||
use ty::{Dynamic, Int, Uint, Infer};
|
use ty::{UnnormalizedProjection, Dynamic, Int, Uint, Infer};
|
||||||
use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
|
use ty::{self, RegionVid, Ty, TyCtxt, TypeFoldable, GenericParamCount, GenericParamDefKind};
|
||||||
use util::nodemap::FxHashSet;
|
use util::nodemap::FxHashSet;
|
||||||
|
|
||||||
@ -1143,6 +1143,11 @@ define_print! {
|
|||||||
}
|
}
|
||||||
Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]),
|
Foreign(def_id) => parameterized(f, subst::Substs::empty(), def_id, &[]),
|
||||||
Projection(ref data) => data.print(f, cx),
|
Projection(ref data) => data.print(f, cx),
|
||||||
|
UnnormalizedProjection(ref data) => {
|
||||||
|
write!(f, "Unnormalized(")?;
|
||||||
|
data.print(f, cx)?;
|
||||||
|
write!(f, ")")
|
||||||
|
}
|
||||||
Opaque(def_id, substs) => {
|
Opaque(def_id, substs) => {
|
||||||
if cx.is_verbose {
|
if cx.is_verbose {
|
||||||
return write!(f, "Opaque({:?}, {:?})", def_id, substs);
|
return write!(f, "Opaque({:?}, {:?})", def_id, substs);
|
||||||
|
@ -173,6 +173,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||||||
}
|
}
|
||||||
ty::Error |
|
ty::Error |
|
||||||
ty::Infer(_) |
|
ty::Infer(_) |
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Projection(..) |
|
ty::Projection(..) |
|
||||||
ty::Opaque(..) |
|
ty::Opaque(..) |
|
||||||
ty::GeneratorWitness(..) |
|
ty::GeneratorWitness(..) |
|
||||||
|
@ -722,6 +722,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||||||
ty::Closure(..) |
|
ty::Closure(..) |
|
||||||
ty::Generator(..) |
|
ty::Generator(..) |
|
||||||
ty::GeneratorWitness(..) |
|
ty::GeneratorWitness(..) |
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Projection(..) |
|
ty::Projection(..) |
|
||||||
ty::Opaque(..) |
|
ty::Opaque(..) |
|
||||||
ty::FnDef(..) => bug!("Unexpected type in foreign function"),
|
ty::FnDef(..) => bug!("Unexpected type in foreign function"),
|
||||||
|
@ -65,9 +65,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedResults {
|
|||||||
ty::Adt(def, _) => {
|
ty::Adt(def, _) => {
|
||||||
if def.variants.is_empty() {
|
if def.variants.is_empty() {
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
check_must_use(cx, def.did, s.span, "")
|
|
||||||
}
|
}
|
||||||
|
check_must_use(cx, def.did, s.span, "")
|
||||||
},
|
},
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
@ -337,21 +336,13 @@ impl EarlyLintPass for UnusedParens {
|
|||||||
AssignOp(.., ref value) => (value, "assigned value", false),
|
AssignOp(.., ref value) => (value, "assigned value", false),
|
||||||
// either function/method call, or something this lint doesn't care about
|
// either function/method call, or something this lint doesn't care about
|
||||||
ref call_or_other => {
|
ref call_or_other => {
|
||||||
let args_to_check;
|
let (args_to_check, call_kind) = match *call_or_other {
|
||||||
let call_kind;
|
Call(_, ref args) => (&args[..], "function"),
|
||||||
match *call_or_other {
|
// first "argument" is self (which sometimes needs parens)
|
||||||
Call(_, ref args) => {
|
MethodCall(_, ref args) => (&args[1..], "method"),
|
||||||
call_kind = "function";
|
|
||||||
args_to_check = &args[..];
|
|
||||||
},
|
|
||||||
MethodCall(_, ref args) => {
|
|
||||||
call_kind = "method";
|
|
||||||
// first "argument" is self (which sometimes needs parens)
|
|
||||||
args_to_check = &args[1..];
|
|
||||||
}
|
|
||||||
// actual catch-all arm
|
// actual catch-all arm
|
||||||
_ => { return; }
|
_ => { return; }
|
||||||
}
|
};
|
||||||
// Don't lint if this is a nested macro expansion: otherwise, the lint could
|
// Don't lint if this is a nested macro expansion: otherwise, the lint could
|
||||||
// trigger in situations that macro authors shouldn't have to care about, e.g.,
|
// trigger in situations that macro authors shouldn't have to care about, e.g.,
|
||||||
// when a parenthesized token tree matched in one macro expansion is matched as
|
// when a parenthesized token tree matched in one macro expansion is matched as
|
||||||
@ -372,16 +363,11 @@ impl EarlyLintPass for UnusedParens {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
||||||
let (value, msg) = match s.node {
|
if let ast::StmtKind::Local(ref local) = s.node {
|
||||||
ast::StmtKind::Local(ref local) => {
|
if let Some(ref value) = local.init {
|
||||||
match local.init {
|
self.check_unused_parens_core(cx, &value, "assigned value", false);
|
||||||
Some(ref value) => (value, "assigned value"),
|
|
||||||
None => return,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
_ => return,
|
}
|
||||||
};
|
|
||||||
self.check_unused_parens_core(cx, &value, msg, false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,9 +400,8 @@ impl UnusedImportBraces {
|
|||||||
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
|
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
|
||||||
if orig_ident.name == keywords::SelfValue.name() {
|
if orig_ident.name == keywords::SelfValue.name() {
|
||||||
return;
|
return;
|
||||||
} else {
|
|
||||||
node_ident = rename.unwrap_or(orig_ident);
|
|
||||||
}
|
}
|
||||||
|
node_ident = rename.unwrap_or(orig_ident);
|
||||||
}
|
}
|
||||||
ast::UseTreeKind::Glob => {
|
ast::UseTreeKind::Glob => {
|
||||||
node_ident = ast::Ident::from_str("*");
|
node_ident = ast::Ident::from_str("*");
|
||||||
|
@ -971,7 +971,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
|
|||||||
|
|
||||||
/// Undefined bytes
|
/// Undefined bytes
|
||||||
impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
|
impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
|
||||||
// FIXME(solson): This is a very naive, slow version.
|
// FIXME: Add a fast version for the common, nonoverlapping case
|
||||||
fn copy_undef_mask(
|
fn copy_undef_mask(
|
||||||
&mut self,
|
&mut self,
|
||||||
src: Pointer,
|
src: Pointer,
|
||||||
|
@ -382,6 +382,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
ty::Error |
|
ty::Error |
|
||||||
ty::Infer(_) |
|
ty::Infer(_) |
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::Projection(..) |
|
ty::Projection(..) |
|
||||||
ty::Param(_) |
|
ty::Param(_) |
|
||||||
ty::GeneratorWitness(_) |
|
ty::GeneratorWitness(_) |
|
||||||
|
@ -272,6 +272,8 @@ fn dtorck_constraint_for_ty<'a, 'gcx, 'tcx>(
|
|||||||
overflows: vec![],
|
overflows: vec![],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
|
|
||||||
ty::Infer(..) | ty::Error => {
|
ty::Infer(..) | ty::Error => {
|
||||||
// By the time this code runs, all type variables ought to
|
// By the time this code runs, all type variables ought to
|
||||||
// be fully resolved.
|
// be fully resolved.
|
||||||
|
@ -124,6 +124,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||||||
ty::Foreign(..) => Some(PointerKind::Thin),
|
ty::Foreign(..) => Some(PointerKind::Thin),
|
||||||
// We should really try to normalize here.
|
// We should really try to normalize here.
|
||||||
ty::Projection(ref pi) => Some(PointerKind::OfProjection(pi)),
|
ty::Projection(ref pi) => Some(PointerKind::OfProjection(pi)),
|
||||||
|
ty::UnnormalizedProjection(..) => bug!("only used with chalk-engine"),
|
||||||
ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)),
|
ty::Opaque(def_id, substs) => Some(PointerKind::OfOpaque(def_id, substs)),
|
||||||
ty::Param(ref p) => Some(PointerKind::OfParam(p)),
|
ty::Param(ref p) => Some(PointerKind::OfParam(p)),
|
||||||
// Insufficient type information.
|
// Insufficient type information.
|
||||||
|
@ -1637,9 +1637,39 @@ fn explicit_predicates_of<'a, 'tcx>(
|
|||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
) -> ty::GenericPredicates<'tcx> {
|
) -> ty::GenericPredicates<'tcx> {
|
||||||
use rustc::hir::*;
|
use rustc::hir::*;
|
||||||
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
|
|
||||||
debug!("explicit_predicates_of(def_id={:?})", def_id);
|
debug!("explicit_predicates_of(def_id={:?})", def_id);
|
||||||
|
|
||||||
|
/// A data structure with unique elements, which preserves order of insertion.
|
||||||
|
/// Preserving the order of insertion is important here so as not to break
|
||||||
|
/// compile-fail UI tests.
|
||||||
|
struct UniquePredicates<'tcx> {
|
||||||
|
predicates: Vec<(ty::Predicate<'tcx>, Span)>,
|
||||||
|
uniques: FxHashSet<(ty::Predicate<'tcx>, Span)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'tcx> UniquePredicates<'tcx> {
|
||||||
|
fn new() -> Self {
|
||||||
|
UniquePredicates {
|
||||||
|
predicates: vec![],
|
||||||
|
uniques: FxHashSet::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn push(&mut self, value: (ty::Predicate<'tcx>, Span)) {
|
||||||
|
if self.uniques.insert(value) {
|
||||||
|
self.predicates.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn extend<I: IntoIterator<Item = (ty::Predicate<'tcx>, Span)>>(&mut self, iter: I) {
|
||||||
|
for value in iter {
|
||||||
|
self.push(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
let node_id = tcx.hir.as_local_node_id(def_id).unwrap();
|
||||||
let node = tcx.hir.get(node_id);
|
let node = tcx.hir.get(node_id);
|
||||||
|
|
||||||
@ -1649,7 +1679,7 @@ fn explicit_predicates_of<'a, 'tcx>(
|
|||||||
let icx = ItemCtxt::new(tcx, def_id);
|
let icx = ItemCtxt::new(tcx, def_id);
|
||||||
let no_generics = hir::Generics::empty();
|
let no_generics = hir::Generics::empty();
|
||||||
|
|
||||||
let mut predicates = vec![];
|
let mut predicates = UniquePredicates::new();
|
||||||
|
|
||||||
let ast_generics = match node {
|
let ast_generics = match node {
|
||||||
Node::TraitItem(item) => &item.generics,
|
Node::TraitItem(item) => &item.generics,
|
||||||
@ -1744,7 +1774,7 @@ fn explicit_predicates_of<'a, 'tcx>(
|
|||||||
// on a trait we need to add in the supertrait bounds and bounds found on
|
// on a trait we need to add in the supertrait bounds and bounds found on
|
||||||
// associated types.
|
// associated types.
|
||||||
if let Some((_trait_ref, _)) = is_trait {
|
if let Some((_trait_ref, _)) = is_trait {
|
||||||
predicates = tcx.super_predicates_of(def_id).predicates;
|
predicates.extend(tcx.super_predicates_of(def_id).predicates);
|
||||||
}
|
}
|
||||||
|
|
||||||
// In default impls, we can assume that the self type implements
|
// In default impls, we can assume that the self type implements
|
||||||
@ -1895,6 +1925,8 @@ fn explicit_predicates_of<'a, 'tcx>(
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut predicates = predicates.predicates;
|
||||||
|
|
||||||
// Subtle: before we store the predicates into the tcx, we
|
// Subtle: before we store the predicates into the tcx, we
|
||||||
// sort them so that predicates like `T: Foo<Item=U>` come
|
// sort them so that predicates like `T: Foo<Item=U>` come
|
||||||
// before uses of `U`. This avoids false ambiguity errors
|
// before uses of `U`. This avoids false ambiguity errors
|
||||||
|
@ -336,6 +336,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||||||
// types, where we use Error as the Self type
|
// types, where we use Error as the Self type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) |
|
||||||
ty::GeneratorWitness(..) |
|
ty::GeneratorWitness(..) |
|
||||||
ty::Infer(..) => {
|
ty::Infer(..) => {
|
||||||
bug!("unexpected type encountered in \
|
bug!("unexpected type encountered in \
|
||||||
|
@ -2737,6 +2737,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
|||||||
|
|
||||||
ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton)
|
ty::Closure(..) | ty::Generator(..) => Tuple(vec![]), // FIXME(pcwalton)
|
||||||
|
|
||||||
|
ty::UnnormalizedProjection(..) => panic!("UnnormalizedProjection"),
|
||||||
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
ty::GeneratorWitness(..) => panic!("GeneratorWitness"),
|
||||||
ty::Infer(..) => panic!("Infer"),
|
ty::Infer(..) => panic!("Infer"),
|
||||||
ty::Error => panic!("Error"),
|
ty::Error => panic!("Error"),
|
||||||
|
@ -217,6 +217,35 @@ pub trait Error: Debug + Display {
|
|||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
|
impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
|
||||||
|
/// Converts a type of [`Error`] into a box of dyn [`Error`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::fmt;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// #[derive(Debug)]
|
||||||
|
/// struct AnError;
|
||||||
|
///
|
||||||
|
/// impl fmt::Display for AnError {
|
||||||
|
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
/// write!(f , "An error")
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Error for AnError {
|
||||||
|
/// fn description(&self) -> &str {
|
||||||
|
/// "Description of an error"
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// let an_error = AnError;
|
||||||
|
/// assert!(0 == mem::size_of_val(&an_error));
|
||||||
|
/// let a_boxed_error = Box::<Error>::from(an_error);
|
||||||
|
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: E) -> Box<dyn Error + 'a> {
|
fn from(err: E) -> Box<dyn Error + 'a> {
|
||||||
Box::new(err)
|
Box::new(err)
|
||||||
}
|
}
|
||||||
@ -224,6 +253,41 @@ impl<'a, E: Error + 'a> From<E> for Box<dyn Error + 'a> {
|
|||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync + 'a> {
|
impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync + 'a> {
|
||||||
|
/// Converts a type of [`Error`] + [`Send`] + [`Sync`] into a box of dyn [`Error`] +
|
||||||
|
/// [`Send`] + [`Sync`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::fmt;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// #[derive(Debug)]
|
||||||
|
/// struct AnError;
|
||||||
|
///
|
||||||
|
/// impl fmt::Display for AnError {
|
||||||
|
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
|
/// write!(f , "An error")
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Error for AnError {
|
||||||
|
/// fn description(&self) -> &str {
|
||||||
|
/// "Description of an error"
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// unsafe impl Send for AnError {}
|
||||||
|
///
|
||||||
|
/// unsafe impl Sync for AnError {}
|
||||||
|
///
|
||||||
|
/// let an_error = AnError;
|
||||||
|
/// assert!(0 == mem::size_of_val(&an_error));
|
||||||
|
/// let a_boxed_error = Box::<Error + Send + Sync>::from(an_error);
|
||||||
|
/// assert!(
|
||||||
|
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
|
fn from(err: E) -> Box<dyn Error + Send + Sync + 'a> {
|
||||||
Box::new(err)
|
Box::new(err)
|
||||||
}
|
}
|
||||||
@ -231,6 +295,19 @@ impl<'a, E: Error + Send + Sync + 'a> From<E> for Box<dyn Error + Send + Sync +
|
|||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl From<String> for Box<dyn Error + Send + Sync> {
|
impl From<String> for Box<dyn Error + Send + Sync> {
|
||||||
|
/// Converts a [`String`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// let a_string_error = "a string error".to_string();
|
||||||
|
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_string_error);
|
||||||
|
/// assert!(
|
||||||
|
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: String) -> Box<dyn Error + Send + Sync> {
|
fn from(err: String) -> Box<dyn Error + Send + Sync> {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct StringError(String);
|
struct StringError(String);
|
||||||
@ -251,6 +328,18 @@ impl From<String> for Box<dyn Error + Send + Sync> {
|
|||||||
|
|
||||||
#[stable(feature = "string_box_error", since = "1.6.0")]
|
#[stable(feature = "string_box_error", since = "1.6.0")]
|
||||||
impl From<String> for Box<dyn Error> {
|
impl From<String> for Box<dyn Error> {
|
||||||
|
/// Converts a [`String`] into a box of dyn [`Error`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// let a_string_error = "a string error".to_string();
|
||||||
|
/// let a_boxed_error = Box::<Error>::from(a_string_error);
|
||||||
|
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(str_err: String) -> Box<dyn Error> {
|
fn from(str_err: String) -> Box<dyn Error> {
|
||||||
let err1: Box<dyn Error + Send + Sync> = From::from(str_err);
|
let err1: Box<dyn Error + Send + Sync> = From::from(str_err);
|
||||||
let err2: Box<dyn Error> = err1;
|
let err2: Box<dyn Error> = err1;
|
||||||
@ -260,6 +349,19 @@ impl From<String> for Box<dyn Error> {
|
|||||||
|
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
|
impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
|
||||||
|
/// Converts a [`str`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// let a_str_error = "a str error";
|
||||||
|
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_str_error);
|
||||||
|
/// assert!(
|
||||||
|
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
|
fn from(err: &'b str) -> Box<dyn Error + Send + Sync + 'a> {
|
||||||
From::from(String::from(err))
|
From::from(String::from(err))
|
||||||
}
|
}
|
||||||
@ -267,6 +369,18 @@ impl<'a, 'b> From<&'b str> for Box<dyn Error + Send + Sync + 'a> {
|
|||||||
|
|
||||||
#[stable(feature = "string_box_error", since = "1.6.0")]
|
#[stable(feature = "string_box_error", since = "1.6.0")]
|
||||||
impl<'a> From<&'a str> for Box<dyn Error> {
|
impl<'a> From<&'a str> for Box<dyn Error> {
|
||||||
|
/// Converts a [`str`] into a box of dyn [`Error`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
///
|
||||||
|
/// let a_str_error = "a str error";
|
||||||
|
/// let a_boxed_error = Box::<Error>::from(a_str_error);
|
||||||
|
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: &'a str) -> Box<dyn Error> {
|
fn from(err: &'a str) -> Box<dyn Error> {
|
||||||
From::from(String::from(err))
|
From::from(String::from(err))
|
||||||
}
|
}
|
||||||
@ -274,6 +388,20 @@ impl<'a> From<&'a str> for Box<dyn Error> {
|
|||||||
|
|
||||||
#[stable(feature = "cow_box_error", since = "1.22.0")]
|
#[stable(feature = "cow_box_error", since = "1.22.0")]
|
||||||
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
|
impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
|
||||||
|
/// Converts a [`Cow`] into a box of dyn [`Error`] + [`Send`] + [`Sync`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
/// use std::borrow::Cow;
|
||||||
|
///
|
||||||
|
/// let a_cow_str_error = Cow::from("a str error");
|
||||||
|
/// let a_boxed_error = Box::<Error + Send + Sync>::from(a_cow_str_error);
|
||||||
|
/// assert!(
|
||||||
|
/// mem::size_of::<Box<dyn Error + Send + Sync>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> {
|
fn from(err: Cow<'b, str>) -> Box<dyn Error + Send + Sync + 'a> {
|
||||||
From::from(String::from(err))
|
From::from(String::from(err))
|
||||||
}
|
}
|
||||||
@ -281,6 +409,19 @@ impl<'a, 'b> From<Cow<'b, str>> for Box<dyn Error + Send + Sync + 'a> {
|
|||||||
|
|
||||||
#[stable(feature = "cow_box_error", since = "1.22.0")]
|
#[stable(feature = "cow_box_error", since = "1.22.0")]
|
||||||
impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
|
impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
|
||||||
|
/// Converts a [`Cow`] into a box of dyn [`Error`].
|
||||||
|
///
|
||||||
|
/// # Examples
|
||||||
|
///
|
||||||
|
/// ```
|
||||||
|
/// use std::error::Error;
|
||||||
|
/// use std::mem;
|
||||||
|
/// use std::borrow::Cow;
|
||||||
|
///
|
||||||
|
/// let a_cow_str_error = Cow::from("a str error");
|
||||||
|
/// let a_boxed_error = Box::<Error>::from(a_cow_str_error);
|
||||||
|
/// assert!(mem::size_of::<Box<dyn Error>>() == mem::size_of_val(&a_boxed_error))
|
||||||
|
/// ```
|
||||||
fn from(err: Cow<'a, str>) -> Box<dyn Error> {
|
fn from(err: Cow<'a, str>) -> Box<dyn Error> {
|
||||||
From::from(String::from(err))
|
From::from(String::from(err))
|
||||||
}
|
}
|
||||||
|
@ -2228,6 +2228,9 @@ impl<'a> State<'a> {
|
|||||||
self.word_nbsp("async")?;
|
self.word_nbsp("async")?;
|
||||||
self.print_capture_clause(capture_clause)?;
|
self.print_capture_clause(capture_clause)?;
|
||||||
self.s.space()?;
|
self.s.space()?;
|
||||||
|
// cbox/ibox in analogy to the `ExprKind::Block` arm above
|
||||||
|
self.cbox(INDENT_UNIT)?;
|
||||||
|
self.ibox(0)?;
|
||||||
self.print_block_with_attrs(blk, attrs)?;
|
self.print_block_with_attrs(blk, attrs)?;
|
||||||
}
|
}
|
||||||
ast::ExprKind::Assign(ref lhs, ref rhs) => {
|
ast::ExprKind::Assign(ref lhs, ref rhs) => {
|
||||||
|
7
src/test/pretty/issue-54752-async-block.rs
Normal file
7
src/test/pretty/issue-54752-async-block.rs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#![feature(async_await)]
|
||||||
|
#![allow(unused_parens)]
|
||||||
|
|
||||||
|
// edition:2018
|
||||||
|
// pp-exact
|
||||||
|
|
||||||
|
fn main() { let _a = (async { }); }
|
@ -5,9 +5,8 @@ LL | #[rustc_dump_program_clauses] //~ ERROR program clause dump
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
||||||
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
|
||||||
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
|
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
|
||||||
= note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo), WellFormed(Self: Foo).
|
= note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo).
|
||||||
|
|
||||||
error: program clause dump
|
error: program clause dump
|
||||||
--> $DIR/lower_env1.rs:19:1
|
--> $DIR/lower_env1.rs:19:1
|
||||||
@ -16,11 +15,10 @@ LL | #[rustc_dump_env_program_clauses] //~ ERROR program clause dump
|
|||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
||||||
= note: FromEnv(Self: Foo) :- FromEnv(Self: Bar).
|
|
||||||
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
|
= note: Implemented(Self: Bar) :- FromEnv(Self: Bar).
|
||||||
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
|
= note: Implemented(Self: Foo) :- FromEnv(Self: Foo).
|
||||||
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
|
= note: Implemented(Self: std::marker::Sized) :- FromEnv(Self: std::marker::Sized).
|
||||||
= note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo), WellFormed(Self: Foo).
|
= note: WellFormed(Self: Bar) :- Implemented(Self: Bar), WellFormed(Self: Foo).
|
||||||
= note: WellFormed(Self: Foo) :- Implemented(Self: Foo).
|
= note: WellFormed(Self: Foo) :- Implemented(Self: Foo).
|
||||||
= note: WellFormed(Self: std::marker::Sized) :- Implemented(Self: std::marker::Sized).
|
= note: WellFormed(Self: std::marker::Sized) :- Implemented(Self: std::marker::Sized).
|
||||||
|
|
||||||
|
@ -71,4 +71,18 @@ fn main() {
|
|||||||
|
|
||||||
"##);
|
"##);
|
||||||
//~^^^ ERROR: there is no argument named `foo`
|
//~^^^ ERROR: there is no argument named `foo`
|
||||||
|
|
||||||
|
// bad syntax in format string with multiple newlines, #53836
|
||||||
|
format!("first number: {}
|
||||||
|
second number: {}
|
||||||
|
third number: {}
|
||||||
|
fourth number: {}
|
||||||
|
fifth number: {}
|
||||||
|
sixth number: {}
|
||||||
|
seventh number: {}
|
||||||
|
eighth number: {}
|
||||||
|
ninth number: {
|
||||||
|
tenth number: {}",
|
||||||
|
1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||||
|
//~^^ ERROR: invalid format string
|
||||||
}
|
}
|
||||||
|
@ -204,5 +204,11 @@ error: there is no argument named `foo`
|
|||||||
LL | {foo}
|
LL | {foo}
|
||||||
| ^^^^^
|
| ^^^^^
|
||||||
|
|
||||||
error: aborting due to 27 previous errors
|
error: invalid format string: expected `'}'`, found `'t'`
|
||||||
|
--> $DIR/ifmt-bad-arg.rs:85:1
|
||||||
|
|
|
||||||
|
LL | tenth number: {}",
|
||||||
|
| ^ expected `}` in format string
|
||||||
|
|
||||||
|
error: aborting due to 28 previous errors
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user