forked from rust-lang/rust
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#67898 - matthewjasper:newtype-index-hygiene…
…, r=Centril Improve hygiene of `newtype_index` `newtype_index` no longer needs `rustc_index::vec::Idx` to be in scope. r? @Centril
- Loading branch information
Showing
13 changed files
with
80 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#![allow(dead_code)] | ||
newtype_index!(struct MyIdx { MAX = 0xFFFF_FFFA }); | ||
|
||
#[test] | ||
fn index_size_is_optimized() { | ||
use std::mem::size_of; | ||
|
||
assert_eq!(size_of::<MyIdx>(), 4); | ||
// Uses 0xFFFF_FFFB | ||
assert_eq!(size_of::<Option<MyIdx>>(), 4); | ||
// Uses 0xFFFF_FFFC | ||
assert_eq!(size_of::<Option<Option<MyIdx>>>(), 4); | ||
// Uses 0xFFFF_FFFD | ||
assert_eq!(size_of::<Option<Option<Option<MyIdx>>>>(), 4); | ||
// Uses 0xFFFF_FFFE | ||
assert_eq!(size_of::<Option<Option<Option<Option<MyIdx>>>>>(), 4); | ||
// Uses 0xFFFF_FFFF | ||
assert_eq!(size_of::<Option<Option<Option<Option<Option<MyIdx>>>>>>(), 4); | ||
// Uses a tag | ||
assert_eq!(size_of::<Option<Option<Option<Option<Option<Option<MyIdx>>>>>>>(), 8); | ||
} | ||
|
||
#[test] | ||
fn range_iterator_iterates_forwards() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!( | ||
range.collect::<Vec<_>>(), | ||
[MyIdx::from_u32(1), MyIdx::from_u32(2), MyIdx::from_u32(3)] | ||
); | ||
} | ||
|
||
#[test] | ||
fn range_iterator_iterates_backwards() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!( | ||
range.rev().collect::<Vec<_>>(), | ||
[MyIdx::from_u32(3), MyIdx::from_u32(2), MyIdx::from_u32(1)] | ||
); | ||
} | ||
|
||
#[test] | ||
fn range_count_is_correct() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!(range.count(), 3); | ||
} | ||
|
||
#[test] | ||
fn range_size_hint_is_correct() { | ||
let range = MyIdx::from_u32(1)..MyIdx::from_u32(4); | ||
assert_eq!(range.size_hint(), (3, Some(3))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/librustc_mir/borrow_check/type_check/liveness/local_use_map.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
use rustc_index::vec::Idx; | ||
use rustc_serialize::{Decoder, Encoder}; | ||
use rustc_span::ExpnId; | ||
use std::fmt; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.