Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
b95bde4
squash of all commits for nth_back on ChunksMut
May 31, 2019
4242206
Re-enable assertions in PPC dist builder
mati865 Jul 19, 2019
3334802
Refactoring use commun code between option, result and accum
Stargateur Jul 22, 2019
e2eb957
Allow lifetime elision in `Pin<&(mut) Self>`
taiki-e May 26, 2019
a1fd4fa
Remove query for `.pin_type()`
taiki-e May 27, 2019
7b9a65e
Make is_self_ty a method on SelfVisitor
taiki-e May 29, 2019
2f64404
Use Set1<Region> instead of Option<Region>
taiki-e May 29, 2019
3096568
add a bevy of new test cases
nikomatsakis Jun 28, 2019
258498a
Update src/test/ui/self/elision/README.md
taiki-e Jul 15, 2019
c1f22c0
Add main functions and check-pass annotations
taiki-e Jul 15, 2019
aab9edc
Minor clean up
taiki-e Jul 15, 2019
8507b8e
Add test for multiple ref-self
taiki-e Jul 15, 2019
1e29052
Add tests for `self: (&)AssocType`
taiki-e Jul 26, 2019
34f59eb
Fix typo
taiki-e Jul 26, 2019
05f67a2
arbitrary_self_types lifetime elision: --bless --compare-mode=nll
taiki-e Jul 27, 2019
8b3f28c
Make more informative error on outer attr after inner
eupn Jul 27, 2019
3eeec1c
Break dependencies between `syntax_ext` and some other crates
petrochenkov Jul 17, 2019
4ad0daa
Move proc macro server into libsyntax
petrochenkov Jul 18, 2019
f6eda99
Move test harness generation into libsyntax_ext
petrochenkov Jul 18, 2019
4d535bd
Move standard library injection into libsyntax_ext
petrochenkov Jul 18, 2019
b5a0e6e
syntax_ext: `proc_macro_decls` -> `proc_macro_harness`
petrochenkov Jul 18, 2019
fc9bfd6
Treat doc comments separately
eupn Jul 27, 2019
2787cb2
Fix failing UI tests
eupn Jul 27, 2019
693be44
Fix ui/parser/attr test
eupn Jul 27, 2019
c0df742
tidy: libcoretest.rs -> unit_tests.rs
petrochenkov Jul 25, 2019
6a4def0
tidy: Fix a regression in `#[test]` detection in libcore
petrochenkov Jul 25, 2019
aecaa03
tidy: Add a check for inline unit tests and benchmarks
petrochenkov Jul 26, 2019
75dfdcb
ci: download awscli from our mirror
pietroalbini Jul 27, 2019
ece18b7
Rollup merge of #61207 - taiki-e:arbitrary_self_types-lifetime-elisio…
Centril Jul 28, 2019
cb8b491
Rollup merge of #62074 - wizAmit:feature/mut_chunks_nth_back, r=scottmcm
Centril Jul 28, 2019
ca0cd73
Rollup merge of #62771 - petrochenkov:depext, r=eddyb
Centril Jul 28, 2019
8f9b8c1
Rollup merge of #62883 - Stargateur:refactoring-adapters, r=scottmcm
Centril Jul 28, 2019
fb6fdd4
Rollup merge of #62949 - mati865:patch-1, r=alexcrichton
Centril Jul 28, 2019
c3c0309
Rollup merge of #62996 - petrochenkov:outest, r=Mark-Simulacrum
Centril Jul 28, 2019
5c70085
Rollup merge of #63038 - eupn:outer-attribute-diag, r=estebank
Centril Jul 28, 2019
34c0f46
Rollup merge of #63050 - pietroalbini:vendor-awscli, r=Mark-Simulacrum
Centril Jul 28, 2019
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
Prev Previous commit
Next Next commit
Remove query for .pin_type()
  • Loading branch information
taiki-e committed Jul 27, 2019
commit a1fd4fa848a11698b9a21bc937f5846dff87920e
66 changes: 32 additions & 34 deletions src/librustc/middle/resolve_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2174,46 +2174,44 @@ impl<'a, 'tcx> LifetimeContext<'a, 'tcx> {
false
};

let mut self_arg = &inputs[0].node;

// Apply `self: &(mut) Self` elision rules even if nested in `Pin`.
loop {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = *self_arg {
if let Res::Def(DefKind::Struct, def_id) = path.res {
if self.tcx.lang_items().pin_type() == Some(def_id) {
if let Some(args) = path
.segments
.last()
.and_then(|segment| segment.args.as_ref())
{
if args.args.len() == 1 {
if let GenericArg::Type(ty) = &args.args[0] {
self_arg = &ty.node;
// Keep dereferencing `self_arg` until we get to non-`Pin`
// types.
continue;
}
}
struct SelfVisitor<'a, F: FnMut(Res) -> bool> {
is_self_ty: F,
map: &'a NamedRegionMap,
lifetime: Option<Region>,
}

impl<'a, F: FnMut(Res) -> bool> Visitor<'a> for SelfVisitor<'a, F> {
fn nested_visit_map<'this>(&'this mut self) -> NestedVisitorMap<'this, 'a> {
NestedVisitorMap::None
}

fn visit_ty(&mut self, ty: &'a hir::Ty) {
if let hir::TyKind::Rptr(lifetime_ref, ref mt) = ty.node {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node
{
if (self.is_self_ty)(path.res) {
self.lifetime = self.map.defs.get(&lifetime_ref.hir_id).copied();
return;
}
}
}
intravisit::walk_ty(self, ty)
}
break;
}

if let hir::TyKind::Rptr(lifetime_ref, ref mt) = *self_arg {
if let hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) = mt.ty.node {
if is_self_ty(path.res) {
if let Some(&lifetime) = self.map.defs.get(&lifetime_ref.hir_id) {
let scope = Scope::Elision {
elide: Elide::Exact(lifetime),
s: self.scope,
};
self.with(scope, |_, this| this.visit_ty(output));
return;
}
}
}
let mut visitor = SelfVisitor {
is_self_ty,
map: self.map,
lifetime: None,
};
visitor.visit_ty(&inputs[0]);
if let Some(lifetime) = visitor.lifetime {
let scope = Scope::Elision {
elide: Elide::Exact(lifetime),
s: self.scope,
};
self.with(scope, |_, this| this.visit_ty(output));
return;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/self/arbitrary_self_types_pin_lifetime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Foo {

type Alias<T> = Pin<T>;
impl Foo {
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> Alias<&Self> { self }
}

struct Bar<T: Unpin, U: Unpin> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ impl Foo {
fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self, f) } //~ ERROR E0623
}

type Alias<T> = Pin<T>;
impl Foo {
fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg } //~ ERROR E0623
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@ LL | fn c(self: Pin<&Self>, f: &Foo, g: &Foo) -> (Pin<&Foo>, &Foo) { (self,
| |
| this parameter and the return type are declared with different lifetimes...

error: aborting due to 2 previous errors
error[E0623]: lifetime mismatch
--> $DIR/arbitrary_self_types_pin_lifetime_mismatch.rs:15:58
|
LL | fn bar<'a>(self: Alias<&Self>, arg: &'a ()) -> &() { arg }
| ------ --- ^^^ ...but data from `arg` is returned here
| |
| this parameter and the return type are declared with different lifetimes...

error: aborting due to 3 previous errors