summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-05-18 11:54:47 +0000
committerbors <bors@rust-lang.org>2019-05-18 11:54:47 +0000
commit02b0ca3adb6078217b34494bd94c6e35af988b5e (patch)
tree36a7aa07cd50d850b8c79c4c422561b24d0b53e5
parentd08ab3137301bb20440809271b1273e88be7f82c (diff)
parent7b38c5232c1932b22dc25f4d96cac28058711403 (diff)
Auto merge of #60922 - pietroalbini:beta-rollup, r=pietroalbini
[beta] Rollup backports Rolled up: * [beta] save-analysis: Pull associated type definition using `qpath_def` #60881 * [beta] Update clippy #60918 Cherry-picked: * Instead of ICEing on incorrect pattern, use delay_span_bug #60641 * Use `delay_span_bug` for "Failed to unify obligation" #60644 r? @ghost
-rw-r--r--src/librustc/middle/mem_categorization.rs12
-rw-r--r--src/librustc/traits/project.rs15
-rw-r--r--src/librustc_save_analysis/lib.rs24
-rw-r--r--src/librustc_typeck/lib.rs2
-rw-r--r--src/test/ui/fn-in-pat.rs16
-rw-r--r--src/test/ui/fn-in-pat.stderr9
-rw-r--r--src/test/ui/issues/issue-60283.rs17
-rw-r--r--src/test/ui/issues/issue-60283.stderr35
m---------src/tools/clippy20
9 files changed, 114 insertions, 36 deletions
diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs
index 1a3fef18404..e52de2519b5 100644
--- a/src/librustc/middle/mem_categorization.rs
+++ b/src/librustc/middle/mem_categorization.rs
@@ -1294,8 +1294,16 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> {
}
}
def => {
- span_bug!(pat.span, "tuple struct pattern didn't resolve \
- to variant or struct {:?}", def);
+ debug!(
+ "tuple struct pattern didn't resolve to variant or struct {:?} at {:?}",
+ def,
+ pat.span,
+ );
+ self.tcx.sess.delay_span_bug(pat.span, &format!(
+ "tuple struct pattern didn't resolve to variant or struct {:?}",
+ def,
+ ));
+ return Err(());
}
};
diff --git a/src/librustc/traits/project.rs b/src/librustc/traits/project.rs
index 360e2323b64..59c0e7a8357 100644
--- a/src/librustc/traits/project.rs
+++ b/src/librustc/traits/project.rs
@@ -1454,13 +1454,18 @@ fn confirm_param_env_candidate<'cx, 'gcx, 'tcx>(
}
}
Err(e) => {
- span_bug!(
- obligation.cause.span,
- "Failed to unify obligation `{:?}` \
- with poly_projection `{:?}`: {:?}",
+ let msg = format!(
+ "Failed to unify obligation `{:?}` with poly_projection `{:?}`: {:?}",
obligation,
poly_cache_entry,
- e);
+ e,
+ );
+ debug!("confirm_param_env_candidate: {}", msg);
+ infcx.tcx.sess.delay_span_bug(obligation.cause.span, &msg);
+ Progress {
+ ty: infcx.tcx.types.err,
+ obligations: vec![],
+ }
}
}
}
diff --git a/src/librustc_save_analysis/lib.rs b/src/librustc_save_analysis/lib.rs
index a363fe11418..d6923b4490d 100644
--- a/src/librustc_save_analysis/lib.rs
+++ b/src/librustc_save_analysis/lib.rs
@@ -23,7 +23,6 @@ use rustc::middle::cstore::ExternCrate;
use rustc::session::config::{CrateType, Input, OutputType};
use rustc::ty::{self, DefIdTree, TyCtxt};
use rustc::{bug, span_bug};
-use rustc_typeck::hir_ty_to_ty;
use rustc_codegen_utils::link::{filename_for_metadata, out_filename};
use rustc_data_structures::sync::Lrc;
@@ -648,6 +647,10 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
Node::Pat(&hir::Pat {
node: hir::PatKind::TupleStruct(ref qpath, ..),
..
+ }) |
+ Node::Ty(&hir::Ty {
+ node: hir::TyKind::Path(ref qpath),
+ ..
}) => {
let hir_id = self.tcx.hir().node_to_hir_id(id);
self.tables.qpath_def(qpath, hir_id)
@@ -658,25 +661,6 @@ impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
..
}) => HirDef::Local(self.tcx.hir().hir_to_node_id(canonical_id)),
- Node::Ty(ty) => if let hir::Ty {
- node: hir::TyKind::Path(ref qpath),
- ..
- } = *ty
- {
- match *qpath {
- hir::QPath::Resolved(_, ref path) => path.def,
- hir::QPath::TypeRelative(..) => {
- let ty = hir_ty_to_ty(self.tcx, ty);
- if let ty::Projection(proj) = ty.sty {
- return HirDef::AssociatedTy(proj.item_def_id);
- }
- HirDef::Err
- }
- }
- } else {
- HirDef::Err
- },
-
_ => HirDef::Err,
}
}
diff --git a/src/librustc_typeck/lib.rs b/src/librustc_typeck/lib.rs
index 4a7b1e67366..710c84a6bc9 100644
--- a/src/librustc_typeck/lib.rs
+++ b/src/librustc_typeck/lib.rs
@@ -379,7 +379,7 @@ pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
}
}
-/// A quasi-deprecated helper used in rustdoc and save-analysis to get
+/// A quasi-deprecated helper used in rustdoc and clippy to get
/// the type from a HIR node.
pub fn hir_ty_to_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, hir_ty: &hir::Ty) -> Ty<'tcx> {
// In case there are any projections etc, find the "environment"
diff --git a/src/test/ui/fn-in-pat.rs b/src/test/ui/fn-in-pat.rs
new file mode 100644
index 00000000000..ed76b2c5db0
--- /dev/null
+++ b/src/test/ui/fn-in-pat.rs
@@ -0,0 +1,16 @@
+struct A {}
+
+impl A {
+ fn new() {}
+}
+
+fn hof<F>(_: F) where F: FnMut(()) {}
+
+fn ice() {
+ hof(|c| match c {
+ A::new() => (), //~ ERROR expected tuple struct/variant, found method
+ _ => ()
+ })
+}
+
+fn main() {}
diff --git a/src/test/ui/fn-in-pat.stderr b/src/test/ui/fn-in-pat.stderr
new file mode 100644
index 00000000000..eee97fe9587
--- /dev/null
+++ b/src/test/ui/fn-in-pat.stderr
@@ -0,0 +1,9 @@
+error[E0164]: expected tuple struct/variant, found method `<A>::new`
+ --> $DIR/fn-in-pat.rs:11:9
+ |
+LL | A::new() => (),
+ | ^^^^^^^^ not a tuple variant or struct
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0164`.
diff --git a/src/test/ui/issues/issue-60283.rs b/src/test/ui/issues/issue-60283.rs
new file mode 100644
index 00000000000..e5a9caa32fa
--- /dev/null
+++ b/src/test/ui/issues/issue-60283.rs
@@ -0,0 +1,17 @@
+pub trait Trait<'a> {
+ type Item;
+}
+
+impl<'a> Trait<'a> for () {
+ type Item = ();
+}
+
+pub fn foo<T, F>(_: T, _: F)
+where T: for<'a> Trait<'a>,
+ F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
+
+fn main() {
+ foo((), drop)
+ //~^ ERROR type mismatch in function arguments
+ //~| ERROR type mismatch resolving
+}
diff --git a/src/test/ui/issues/issue-60283.stderr b/src/test/ui/issues/issue-60283.stderr
new file mode 100644
index 00000000000..54cc2f3a034
--- /dev/null
+++ b/src/test/ui/issues/issue-60283.stderr
@@ -0,0 +1,35 @@
+error[E0631]: type mismatch in function arguments
+ --> $DIR/issue-60283.rs:14:5
+ |
+LL | foo((), drop)
+ | ^^^
+ | |
+ | expected signature of `for<'a> fn(<() as Trait<'a>>::Item) -> _`
+ | found signature of `fn(_) -> _`
+ |
+note: required by `foo`
+ --> $DIR/issue-60283.rs:9:1
+ |
+LL | / pub fn foo<T, F>(_: T, _: F)
+LL | | where T: for<'a> Trait<'a>,
+LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
+ | |_________________________________________________^
+
+error[E0271]: type mismatch resolving `for<'a> <fn(_) {std::mem::drop::<_>} as std::ops::FnOnce<(<() as Trait<'a>>::Item,)>>::Output == ()`
+ --> $DIR/issue-60283.rs:14:5
+ |
+LL | foo((), drop)
+ | ^^^ expected bound lifetime parameter 'a, found concrete lifetime
+ |
+note: required by `foo`
+ --> $DIR/issue-60283.rs:9:1
+ |
+LL | / pub fn foo<T, F>(_: T, _: F)
+LL | | where T: for<'a> Trait<'a>,
+LL | | F: for<'a> FnMut(<T as Trait<'a>>::Item) {}
+ | |_________________________________________________^
+
+error: aborting due to 2 previous errors
+
+Some errors occurred: E0271, E0631.
+For more information about an error, try `rustc --explain E0271`.
diff --git a/src/tools/clippy b/src/tools/clippy
-Subproject 37f5c1ec734f806fe98930b8d5f54f00013f06f
+Subproject 265318dba93a3363255a4d8eac9aefd53a05673