Skip to content

Commit

Permalink
Auto merge of #74958 - Mark-Simulacrum:stable-next, r=pnkfelix
Browse files Browse the repository at this point in the history
[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
  • Loading branch information
bors committed Jul 31, 2020
2 parents c367798 + fcd1712 commit d068a61
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 53 deletions.
9 changes: 9 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -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)
==========================

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_middle/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
26 changes: 7 additions & 19 deletions src/librustc_resolve/late.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 0 additions & 12 deletions src/test/ui/issues/issue-74539.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/ui/issues/issue-74539.stderr

This file was deleted.

7 changes: 7 additions & 0 deletions src/test/ui/issues/issue-74954.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// check-pass

fn main() {
if let Some([b'@', filename @ ..]) = Some(b"@abc123") {
println!("filename {:?}", filename);
}
}
25 changes: 25 additions & 0 deletions src/test/ui/rfc-2091-track-caller/tracked-trait-obj.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit d068a61

Please sign in to comment.