about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-07-31 14:21:18 +0000
committerbors <bors@rust-lang.org>2020-07-31 14:21:18 +0000
commitd068a6103e8b834820e26d72830ae7c668049b5c (patch)
tree76270eea100819a9fee609bdd13f0f62145a6141
parentc367798cfd3817ca6ae908ce675d1d99242af148 (diff)
parentfcd1712627e21618228057396d3b62e039c21544 (diff)
downloadrust-d068a6103e8b834820e26d72830ae7c668049b5c.tar.gz
rust-d068a6103e8b834820e26d72830ae7c668049b5c.zip
Auto merge of #74958 - Mark-Simulacrum:stable-next, r=pnkfelix
[stable] 1.45.2 release

This is intended to fix the stable breakage noted in #74954, but does *not* close that issue -- there remains investigation and likely nightly/beta fixes need to be issued as well.

r? @pnkfelix
-rw-r--r--RELEASES.md9
-rw-r--r--src/librustc_middle/ty/instance.rs2
-rw-r--r--src/librustc_resolve/late.rs26
-rw-r--r--src/test/ui/issues/issue-74539.rs12
-rw-r--r--src/test/ui/issues/issue-74539.stderr21
-rw-r--r--src/test/ui/issues/issue-74954.rs7
-rw-r--r--src/test/ui/rfc-2091-track-caller/tracked-trait-obj.rs25
7 files changed, 49 insertions, 53 deletions
diff --git a/RELEASES.md b/RELEASES.md
index 204741bec5a..8657cd2ab65 100644
--- a/RELEASES.md
+++ b/RELEASES.md
@@ -1,3 +1,12 @@
+Version 1.45.2 (2020-08-03)
+==========================
+
+* [Fix bindings in tuple struct patterns][74954]
+* [Fix track_caller integration with trait objects][74784]
+
+[74954]: https://github.com/rust-lang/rust/issues/74954
+[74784]: https://github.com/rust-lang/rust/issues/74784
+
 Version 1.45.1 (2020-07-30)
 ==========================
 
diff --git a/src/librustc_middle/ty/instance.rs b/src/librustc_middle/ty/instance.rs
index 1ce079821a2..b3083fa3b37 100644
--- a/src/librustc_middle/ty/instance.rs
+++ b/src/librustc_middle/ty/instance.rs
@@ -345,7 +345,7 @@ impl<'tcx> Instance<'tcx> {
             debug!(" => associated item with unsizeable self: Self");
             Some(Instance { def: InstanceDef::VtableShim(def_id), substs })
         } else {
-            Instance::resolve(tcx, param_env, def_id, substs).ok().flatten()
+            Instance::resolve_for_fn_ptr(tcx, param_env, def_id, substs)
         }
     }
 
diff --git a/src/librustc_resolve/late.rs b/src/librustc_resolve/late.rs
index 9577a21c743..3b49b3b6ff7 100644
--- a/src/librustc_resolve/late.rs
+++ b/src/librustc_resolve/late.rs
@@ -1407,30 +1407,18 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
         pat_src: PatternSource,
         bindings: &mut SmallVec<[(PatBoundCtx, FxHashSet<Ident>); 1]>,
     ) {
-        let is_tuple_struct_pat = matches!(pat.kind, PatKind::TupleStruct(_, _));
-
         // Visit all direct subpatterns of this pattern.
         pat.walk(&mut |pat| {
             debug!("resolve_pattern pat={:?} node={:?}", pat, pat.kind);
             match pat.kind {
-                // In tuple struct patterns ignore the invalid `ident @ ...`.
-                // It will be handled as an error by the AST lowering.
                 PatKind::Ident(bmode, ident, ref sub) => {
-                    if is_tuple_struct_pat && sub.as_ref().filter(|p| p.is_rest()).is_some() {
-                        self.r
-                            .session
-                            .delay_span_bug(ident.span, "ident in tuple pattern is invalid");
-                    } else {
-                        // First try to resolve the identifier as some existing entity,
-                        // then fall back to a fresh binding.
-                        let has_sub = sub.is_some();
-                        let res = self
-                            .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub)
-                            .unwrap_or_else(|| {
-                                self.fresh_binding(ident, pat.id, pat_src, bindings)
-                            });
-                        self.r.record_partial_res(pat.id, PartialRes::new(res));
-                    }
+                    // First try to resolve the identifier as some existing entity,
+                    // then fall back to a fresh binding.
+                    let has_sub = sub.is_some();
+                    let res = self
+                        .try_resolve_as_non_binding(pat_src, pat, bmode, ident, has_sub)
+                        .unwrap_or_else(|| self.fresh_binding(ident, pat.id, pat_src, bindings));
+                    self.r.record_partial_res(pat.id, PartialRes::new(res));
                 }
                 PatKind::TupleStruct(ref path, ..) => {
                     self.smart_resolve_path(pat.id, None, path, PathSource::TupleStruct);
diff --git a/src/test/ui/issues/issue-74539.rs b/src/test/ui/issues/issue-74539.rs
deleted file mode 100644
index 75632d11c1d..00000000000
--- a/src/test/ui/issues/issue-74539.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-enum E {
-    A(u8, u8),
-}
-
-fn main() {
-    let e = E::A(2, 3);
-    match e {
-        E::A(x @ ..) => {  //~ ERROR `x @` is not allowed in a tuple
-            x //~ ERROR cannot find value `x` in this scope
-        }
-    };
-}
diff --git a/src/test/ui/issues/issue-74539.stderr b/src/test/ui/issues/issue-74539.stderr
deleted file mode 100644
index 94526dcd7cb..00000000000
--- a/src/test/ui/issues/issue-74539.stderr
+++ /dev/null
@@ -1,21 +0,0 @@
-error[E0425]: cannot find value `x` in this scope
-  --> $DIR/issue-74539.rs:9:13
-   |
-LL |             x
-   |             ^ help: a local variable with a similar name exists: `e`
-
-error: `x @` is not allowed in a tuple struct
-  --> $DIR/issue-74539.rs:8:14
-   |
-LL |         E::A(x @ ..) => {
-   |              ^^^^^^ this is only allowed in slice patterns
-   |
-   = help: remove this and bind each tuple field independently
-help: if you don't need to use the contents of x, discard the tuple's remaining fields
-   |
-LL |         E::A(..) => {
-   |              ^^
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0425`.
diff --git a/src/test/ui/issues/issue-74954.rs b/src/test/ui/issues/issue-74954.rs
new file mode 100644
index 00000000000..269ec3c7abe
--- /dev/null
+++ b/src/test/ui/issues/issue-74954.rs
@@ -0,0 +1,7 @@
+// check-pass
+
+fn main() {
+    if let Some([b'@', filename @ ..]) = Some(b"@abc123") {
+        println!("filename {:?}", filename);
+    }
+}
diff --git a/src/test/ui/rfc-2091-track-caller/tracked-trait-obj.rs b/src/test/ui/rfc-2091-track-caller/tracked-trait-obj.rs
new file mode 100644
index 00000000000..e41b1d2dd48
--- /dev/null
+++ b/src/test/ui/rfc-2091-track-caller/tracked-trait-obj.rs
@@ -0,0 +1,25 @@
+// run-pass
+
+#![feature(track_caller)]
+
+trait Tracked {
+    #[track_caller]
+    fn handle(&self) {
+        let location = std::panic::Location::caller();
+        assert_eq!(location.file(), file!());
+        // we only call this via trait object, so the def site should *always* be returned
+        assert_eq!(location.line(), line!() - 4);
+        assert_eq!(location.column(), 5);
+    }
+}
+
+impl Tracked for () {}
+impl Tracked for u8 {}
+
+fn main() {
+    let tracked: &dyn Tracked = &5u8;
+    tracked.handle();
+
+    const TRACKED: &dyn Tracked = &();
+    TRACKED.handle();
+}