Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 9 pull requests #41093

Closed
wants to merge 31 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
57009ca
Identify missing item category in `impl`s
estebank Mar 25, 2017
c963d61
Simplify error output
estebank Mar 28, 2017
68d1781
First attempt at global_asm! macro
mrhota Mar 16, 2017
c54f935
Expand _ into explicit variants in match
mrhota Mar 17, 2017
4ed08b5
Add new TransItem for global_asm trans
mrhota Mar 21, 2017
60cde93
Remove unused str_style field
mrhota Mar 24, 2017
b068d38
Ensure walk_item visits GlobalAsm NodeId
mrhota Mar 30, 2017
f44a689
Expose LLVM appendModuleInlineAsm
mrhota Mar 22, 2017
4d46f54
Update unstable book with global_asm feature
mrhota Mar 21, 2017
907ba1b
Add global_asm tests
mrhota Mar 22, 2017
8ad8ba6
Update cargo submodule
alexcrichton Apr 1, 2017
b946ecd
Suggest using enum when a variant is used as a type
estebank Mar 23, 2017
7b89bd7
Add ptr::offset_to
Amanieu Mar 31, 2017
8f31e19
Merge branch 'master' into issue-40006
estebank Apr 3, 2017
73f6f5e
Sort enum suggestions
estebank Apr 3, 2017
4143d40
save-analysis: only index path references once
nrc Mar 8, 2017
ccdbb31
save-analysis: index extern blocks
nrc Mar 8, 2017
d76daf5
rebased
nrc Mar 15, 2017
f07ebd6
Simplify HashMap Bucket interface
arthurprs Mar 15, 2017
56902fb
Fixes other targets rustlibs installation
Mar 13, 2017
1f70247
Add tracking issue for offset_to
Amanieu Apr 5, 2017
44bcd26
Reduce a table used for `Debug` impl of `str`.
lifthrasiir Mar 21, 2017
580e8d7
Rollup merge of #40348 - nrc:save-extern-fn, r=eddyb
frewsxcv Apr 5, 2017
ff25317
Rollup merge of #40479 - sezaru:master, r=alexcrichton
frewsxcv Apr 5, 2017
c7bdcce
Rollup merge of #40561 - arthurprs:hm-adapt2, r=pczarn
frewsxcv Apr 5, 2017
14f0dba
Rollup merge of #40702 - mrhota:global_asm, r=arielb1
frewsxcv Apr 5, 2017
a276d9c
Rollup merge of #40709 - lifthrasiir:leaner-unicode-debug-str, r=alex…
frewsxcv Apr 5, 2017
4408748
Rollup merge of #40775 - estebank:variant-as-type, r=petrochenkov
frewsxcv Apr 5, 2017
30f3a38
Rollup merge of #40815 - estebank:issue-40006, r=GuillaumeGomez
frewsxcv Apr 5, 2017
9f88677
Rollup merge of #40943 - Amanieu:offset_to, r=alexcrichton
frewsxcv Apr 5, 2017
bfe32ce
Rollup merge of #40996 - alexcrichton:update-cargo, r=alexcrichton
frewsxcv Apr 5, 2017
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
9 changes: 7 additions & 2 deletions src/bootstrap/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ pub fn install(build: &Build, stage: u32, host: &str) {
install_sh(&build, "docs", "rust-docs", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}

for target in build.config.target.iter() {
install_sh(&build, "std", "rust-std", stage, target, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}

if build.config.rust_save_analysis {
install_sh(&build, "analysis", "rust-analysis", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
}
install_sh(&build, "std", "rust-std", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);

install_sh(&build, "rustc", "rustc", stage, host, &prefix,
&docdir, &libdir, &mandir, &empty_dir);
t!(fs::remove_dir_all(&empty_dir));
Expand Down
2 changes: 2 additions & 0 deletions src/doc/unstable-book/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
- [future_atomic_orderings](future-atomic-orderings.md)
- [generic_param_attrs](generic-param-attrs.md)
- [get_type_id](get-type-id.md)
- [global_asm](global_asm.md)
- [heap_api](heap-api.md)
- [i128](i128.md)
- [i128_type](i128-type.md)
Expand Down Expand Up @@ -123,6 +124,7 @@
- [no_debug](no-debug.md)
- [non_ascii_idents](non-ascii-idents.md)
- [nonzero](nonzero.md)
- [offset_to](offset-to.md)
- [omit_gdb_pretty_printer_section](omit-gdb-pretty-printer-section.md)
- [on_unimplemented](on-unimplemented.md)
- [once_poison](once-poison.md)
Expand Down
2 changes: 2 additions & 0 deletions src/doc/unstable-book/src/asm.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,5 @@ constraints, etc.

[llvm-docs]: http://llvm.org/docs/LangRef.html#inline-assembler-expressions

If you need more power and don't mind losing some of the niceties of
`asm!`, check out [global_asm](global_asm.html).
78 changes: 78 additions & 0 deletions src/doc/unstable-book/src/global_asm.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# `global_asm`

The tracking issue for this feature is: [#35119]

[#35119]: https://github.com/rust-lang/rust/issues/35119

------------------------

The `global_asm!` macro allows the programmer to write arbitrary
assembly outside the scope of a function body, passing it through
`rustc` and `llvm` to the assembler. The macro is a no-frills
interface to LLVM's concept of [module-level inline assembly]. That is,
all caveats applicable to LLVM's module-level inline assembly apply
to `global_asm!`.

[module-level inline assembly]: http://llvm.org/docs/LangRef.html#module-level-inline-assembly

`global_asm!` fills a role not currently satisfied by either `asm!`
or `#[naked]` functions. The programmer has _all_ features of the
assembler at their disposal. The linker will expect to resolve any
symbols defined in the inline assembly, modulo any symbols marked as
external. It also means syntax for directives and assembly follow the
conventions of the assembler in your toolchain.

A simple usage looks like this:

```rust,ignore
# #![feature(global_asm)]
# you also need relevant target_arch cfgs
global_asm!(include_str!("something_neato.s"));
```

And a more complicated usage looks like this:

```rust,ignore
# #![feature(global_asm)]
# #![cfg(any(target_arch = "x86", target_arch = "x86_64"))]

pub mod sally {
global_asm!(r#"
.global foo
foo:
jmp baz
"#);

#[no_mangle]
pub unsafe extern "C" fn baz() {}
}

// the symbols `foo` and `bar` are global, no matter where
// `global_asm!` was used.
extern "C" {
fn foo();
fn bar();
}

pub mod harry {
global_asm!(r#"
.global bar
bar:
jmp quux
"#);

#[no_mangle]
pub unsafe extern "C" fn quux() {}
}
```

You may use `global_asm!` multiple times, anywhere in your crate, in
whatever way suits you. The effect is as if you concatenated all
usages and placed the larger, single usage in the crate root.

------------------------

If you don't need quite as much power and flexibility as
`global_asm!` provides, and you don't mind restricting your inline
assembly to `fn` bodies only, you might try the [asm](asm.html)
feature instead.
7 changes: 7 additions & 0 deletions src/doc/unstable-book/src/offset-to.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# `offset_to`

The tracking issue for this feature is: [#41079]

[#41079]: https://github.com/rust-lang/rust/issues/41079

------------------------
132 changes: 98 additions & 34 deletions src/etc/char_private.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,66 @@ def get_codepoints(f):
for c in range(prev_codepoint + 1, NUM_CODEPOINTS):
yield Codepoint(c, None)

def compress_singletons(singletons):
uppers = [] # (upper, # items in lowers)
lowers = []

for i in singletons:
upper = i >> 8
lower = i & 0xff
if len(uppers) == 0 or uppers[-1][0] != upper:
uppers.append((upper, 1))
else:
upper, count = uppers[-1]
uppers[-1] = upper, count + 1
lowers.append(lower)

return uppers, lowers

def compress_normal(normal):
# lengths 0x00..0x7f are encoded as 00, 01, ..., 7e, 7f
# lengths 0x80..0x7fff are encoded as 80 80, 80 81, ..., ff fe, ff ff
compressed = [] # [truelen, (truelenaux), falselen, (falselenaux)]

prev_start = 0
for start, count in normal:
truelen = start - prev_start
falselen = count
prev_start = start + count

assert truelen < 0x8000 and falselen < 0x8000
entry = []
if truelen > 0x7f:
entry.append(0x80 | (truelen >> 8))
entry.append(truelen & 0xff)
else:
entry.append(truelen & 0x7f)
if falselen > 0x7f:
entry.append(0x80 | (falselen >> 8))
entry.append(falselen & 0xff)
else:
entry.append(falselen & 0x7f)

compressed.append(entry)

return compressed

def print_singletons(uppers, lowers, uppersname, lowersname):
print("const {}: &'static [(u8, u8)] = &[".format(uppersname))
for u, c in uppers:
print(" ({:#04x}, {}),".format(u, c))
print("];")
print("const {}: &'static [u8] = &[".format(lowersname))
for i in range(0, len(lowers), 8):
print(" {}".format(" ".join("{:#04x},".format(l) for l in lowers[i:i+8])))
print("];")

def print_normal(normal, normalname):
print("const {}: &'static [u8] = &[".format(normalname))
for v in normal:
print(" {}".format(" ".join("{:#04x},".format(i) for i in v)))
print("];")

def main():
file = get_file("http://www.unicode.org/Public/UNIDATA/UnicodeData.txt")

Expand Down Expand Up @@ -111,6 +171,11 @@ def main():
else:
normal0.append((a, b - a))

singletons0u, singletons0l = compress_singletons(singletons0)
singletons1u, singletons1l = compress_singletons(singletons1)
normal0 = compress_normal(normal0)
normal1 = compress_normal(normal1)

print("""\
// Copyright 2012-2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
Expand All @@ -125,38 +190,49 @@ def main():
// NOTE: The following code was generated by "src/etc/char_private.py",
// do not edit directly!

use slice::SliceExt;

fn check(x: u16, singletons: &[u16], normal: &[u16]) -> bool {
for &s in singletons {
if x == s {
return false;
} else if x < s {
fn check(x: u16, singletonuppers: &[(u8, u8)], singletonlowers: &[u8],
normal: &[u8]) -> bool {
let xupper = (x >> 8) as u8;
let mut lowerstart = 0;
for &(upper, lowercount) in singletonuppers {
let lowerend = lowerstart + lowercount as usize;
if xupper == upper {
for &lower in &singletonlowers[lowerstart..lowerend] {
if lower == x as u8 {
return false;
}
}
} else if xupper < upper {
break;
}
lowerstart = lowerend;
}
for w in normal.chunks(2) {
let start = w[0];
let len = w[1];
let difference = (x as i32) - (start as i32);
if 0 <= difference {
if difference < len as i32 {
return false;
}

let mut x = x as i32;
let mut normal = normal.iter().cloned();
let mut current = true;
while let Some(v) = normal.next() {
let len = if v & 0x80 != 0 {
((v & 0x7f) as i32) << 8 | normal.next().unwrap() as i32
} else {
v as i32
};
x -= len;
if x < 0 {
break;
}
current = !current;
}
true
current
}

pub fn is_printable(x: char) -> bool {
let x = x as u32;
let lower = x as u16;
if x < 0x10000 {
check(lower, SINGLETONS0, NORMAL0)
check(lower, SINGLETONS0U, SINGLETONS0L, NORMAL0)
} else if x < 0x20000 {
check(lower, SINGLETONS1, NORMAL1)
check(lower, SINGLETONS1U, SINGLETONS1L, NORMAL1)
} else {\
""")
for a, b in extra:
Expand All @@ -169,22 +245,10 @@ def main():
}\
""")
print()
print("const SINGLETONS0: &'static [u16] = &[")
for s in singletons0:
print(" 0x{:x},".format(s))
print("];")
print("const SINGLETONS1: &'static [u16] = &[")
for s in singletons1:
print(" 0x{:x},".format(s))
print("];")
print("const NORMAL0: &'static [u16] = &[")
for a, b in normal0:
print(" 0x{:x}, 0x{:x},".format(a, b))
print("];")
print("const NORMAL1: &'static [u16] = &[")
for a, b in normal1:
print(" 0x{:x}, 0x{:x},".format(a, b))
print("];")
print_singletons(singletons0u, singletons0l, 'SINGLETONS0U', 'SINGLETONS0L')
print_singletons(singletons1u, singletons1l, 'SINGLETONS1U', 'SINGLETONS1L')
print_normal(normal0, 'NORMAL0')
print_normal(normal1, 'NORMAL1')

if __name__ == '__main__':
main()
1 change: 1 addition & 0 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#![feature(untagged_unions)]
#![cfg_attr(not(test), feature(str_checked_slicing))]
#![cfg_attr(test, feature(rand, test))]
#![feature(offset_to)]

#![no_std]

Expand Down
12 changes: 4 additions & 8 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2074,14 +2074,10 @@ impl<T> Iterator for IntoIter<T> {

#[inline]
fn size_hint(&self) -> (usize, Option<usize>) {
let diff = (self.end as usize) - (self.ptr as usize);
let size = mem::size_of::<T>();
let exact = diff /
(if size == 0 {
1
} else {
size
});
let exact = match self.ptr.offset_to(self.end) {
Some(x) => x as usize,
None => (self.end as usize).wrapping_sub(self.ptr as usize),
};
(exact, Some(exact))
}

Expand Down
Loading