Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
fix feature error, test fallout
  • Loading branch information
llogiq committed Sep 8, 2016
commit 76a2f9f4542ccb15d6eb2426b162ce91094f04e2
18 changes: 9 additions & 9 deletions src/librustc_typeck/rscope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,17 +229,9 @@ impl<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> StaticRscope<'a, 'gcx, 'tcx> {

impl<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> RegionScope for StaticRscope<'a, 'gcx, 'tcx> {
fn anon_regions(&self,
_span: Span,
span: Span,
count: usize)
-> Result<Vec<ty::Region>, Option<Vec<ElisionFailureInfo>>> {
Ok(vec![ty::ReStatic; count])
}

fn object_lifetime_default(&self, span: Span) -> Option<ty::Region> {
Some(self.base_object_lifetime_default(span))
}

fn base_object_lifetime_default(&self, span: Span) -> ty::Region {
if !self.tcx.sess.features.borrow().static_in_const {
self.tcx
.sess
Expand All @@ -248,6 +240,14 @@ impl<'a, 'gcx: 'a + 'tcx, 'tcx: 'a> RegionScope for StaticRscope<'a, 'gcx, 'tcx>
`static_in_const` feature, see #35897")
.emit();
}
Ok(vec![ty::ReStatic; count])
}

fn object_lifetime_default(&self, span: Span) -> Option<ty::Region> {
Some(self.base_object_lifetime_default(span))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see the problem; these routines should be the same as for elidable rscope:

    fn object_lifetime_default(&self, span: Span) -> Option<ty::Region> {
        // Per RFC #599, object-lifetimes default to 'static unless
        // overridden by context, and this takes precedence over
        // lifetime elision.
        Some(self.base_object_lifetime_default(span))
    }

    fn base_object_lifetime_default(&self, _span: Span) -> ty::Region {
        ty::ReStatic
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I report the error in anon_regions(..) then?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I report the error in anon_regions(..) then?

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, done.

}

fn base_object_lifetime_default(&self, _span: Span) -> ty::Region {
ty::ReStatic
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/test/compile-fail/const-unsized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const CONST_0: Debug+Sync = *(&0 as &(Debug+Sync));
//~| NOTE `std::fmt::Debug + Sync + 'static: std::marker::Sized` not satisfied
//~| NOTE does not have a constant size known at compile-time
//~| NOTE constant expressions must have a statically known size
//~| ERROR this needs a `'static` lifetime or the `static_in_const` feature

const CONST_FOO: str = *"foo";
//~^ ERROR `str: std::marker::Sized` is not satisfied
Expand All @@ -28,7 +27,6 @@ static STATIC_1: Debug+Sync = *(&1 as &(Debug+Sync));
//~| NOTE `std::fmt::Debug + Sync + 'static: std::marker::Sized` not satisfied
//~| NOTE does not have a constant size known at compile-time
//~| NOTE constant expressions must have a statically known size
//~| ERROR this needs a `'static` lifetime or the `static_in_const` feature

static STATIC_BAR: str = *"bar";
//~^ ERROR `str: std::marker::Sized` is not satisfied
Expand Down
1 change: 0 additions & 1 deletion src/test/compile-fail/issue-24446.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ fn main() {
static foo: Fn() -> u32 = || -> u32 {
//~^ ERROR: mismatched types
//~| ERROR: `std::ops::Fn() -> u32 + 'static: std::marker::Sized` is not satisfied
//~| ERROR: this needs a `'static` lifetime or the `static_in_const` feature
0
};
}