Skip to content

Commit a3dcb9f

Browse files
committed
---
yaml --- r: 138977 b: refs/heads/try2 c: 05c1032 h: refs/heads/master i: 138975: 75acddc v: v3
1 parent eb16db2 commit a3dcb9f

File tree

307 files changed

+1423
-1878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

307 files changed

+1423
-1878
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: ab5472a7244896df20ceb7a12d9d30afc838f004
8+
refs/heads/try2: 05c103238d977fe8c5d6b614f21f581069373524
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/doc/rust.md

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ do drop
212212
else enum extern
213213
false fn for
214214
if impl
215-
let loop
215+
let log loop
216216
match mod mut
217217
priv pub pure
218218
ref return
@@ -805,20 +805,21 @@ Use declarations support a number of "convenience" notations:
805805
An example of `use` declarations:
806806

807807
~~~~
808+
use foo = core::info;
808809
use core::float::sin;
809810
use core::str::{slice, to_upper};
810811
use core::option::Some;
811812
812813
fn main() {
813-
// Equivalent to 'info!(core::float::sin(1.0));'
814-
info!(sin(1.0));
814+
// Equivalent to 'log(core::info, core::float::sin(1.0));'
815+
log(foo, sin(1.0));
815816
816-
// Equivalent to 'info!(core::option::Some(1.0));'
817-
info!(Some(1.0));
817+
// Equivalent to 'log(core::info, core::option::Some(1.0));'
818+
log(info, Some(1.0));
818819
819-
// Equivalent to
820-
// 'info!(core::str::to_upper(core::str::slice("foo", 0, 1)));'
821-
info!(to_upper(slice("foo", 0, 1)));
820+
// Equivalent to 'log(core::info,
821+
// core::str::to_upper(core::str::slice("foo", 0, 1)));'
822+
log(info, to_upper(slice("foo", 0, 1)));
822823
}
823824
~~~~
824825

@@ -989,7 +990,7 @@ output slot type would normally be. For example:
989990

990991
~~~~
991992
fn my_err(s: &str) -> ! {
992-
info!(s);
993+
log(info, s);
993994
fail!();
994995
}
995996
~~~~
@@ -2396,6 +2397,58 @@ fn max(a: int, b: int) -> int {
23962397
}
23972398
~~~~
23982399

2400+
### Log expressions
2401+
2402+
~~~~~~~~{.ebnf .gram}
2403+
log_expr : "log" '(' level ',' expr ')' ;
2404+
~~~~~~~~
2405+
2406+
Evaluating a `log` expression may, depending on runtime configuration, cause a
2407+
value to be appended to an internal diagnostic logging buffer provided by the
2408+
runtime or emitted to a system console. Log expressions are enabled or
2409+
disabled dynamically at run-time on a per-task and per-item basis. See
2410+
[logging system](#logging-system).
2411+
2412+
Each `log` expression must be provided with a *level* argument in
2413+
addition to the value to log. The logging level is a `u32` value, where
2414+
lower levels indicate more-urgent levels of logging. By default, the lowest
2415+
four logging levels (`1_u32 ... 4_u32`) are predefined as the constants
2416+
`error`, `warn`, `info` and `debug` in the `core` library.
2417+
2418+
Additionally, the macros `error!`, `warn!`, `info!` and `debug!` are defined
2419+
in the default syntax-extension namespace. These expand into calls to the
2420+
logging facility composed with calls to the `fmt!` string formatting
2421+
syntax-extension.
2422+
2423+
The following examples all produce the same output, logged at the `error`
2424+
logging level:
2425+
2426+
~~~~
2427+
# let filename = "bulbasaur";
2428+
2429+
// Full version, logging a value.
2430+
log(core::error, ~"file not found: " + filename);
2431+
2432+
// Log-level abbreviated, since core::* is used by default.
2433+
log(error, ~"file not found: " + filename);
2434+
2435+
// Formatting the message using a format-string and fmt!
2436+
log(error, fmt!("file not found: %s", filename));
2437+
2438+
// Using the error! macro, that expands to the previous call.
2439+
error!("file not found: %s", filename);
2440+
~~~~
2441+
2442+
A `log` expression is *not evaluated* when logging at the specified logging-level, module or task is disabled at runtime.
2443+
This makes inactive `log` expressions very cheap;
2444+
they should be used extensively in Rust code, as diagnostic aids,
2445+
as they add little overhead beyond a single integer-compare and branch at runtime.
2446+
2447+
Logging is presently implemented as a language built-in feature,
2448+
as it makes use of compiler-provided, per-module data tables and flags.
2449+
In the future, logging will move into a library, and will no longer be a core expression type.
2450+
It is therefore recommended to use the macro forms of logging (`error!`, `debug!`, etc.) to minimize disruption in code that uses logging.
2451+
23992452

24002453
# Type system
24012454

@@ -3096,7 +3149,7 @@ communication facilities.
30963149

30973150
The runtime contains a system for directing [logging
30983151
expressions](#log-expressions) to a logging console and/or internal logging
3099-
buffers. Logging can be enabled per module.
3152+
buffers. Logging expressions can be enabled per module.
31003153

31013154
Logging output is enabled by setting the `RUST_LOG` environment
31023155
variable. `RUST_LOG` accepts a logging specification made up of a

branches/try2/doc/tutorial.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ unit, `()`, as the empty tuple if you like).
744744
~~~~
745745
let mytup: (int, int, float) = (10, 20, 30.0);
746746
match mytup {
747-
(a, b, c) => info!(a + b + (c as int))
747+
(a, b, c) => log(info, a + b + (c as int))
748748
}
749749
~~~~
750750

@@ -760,7 +760,7 @@ For example:
760760
struct MyTup(int, int, float);
761761
let mytup: MyTup = MyTup(10, 20, 30.0);
762762
match mytup {
763-
MyTup(a, b, c) => info!(a + b + (c as int))
763+
MyTup(a, b, c) => log(info, a + b + (c as int))
764764
}
765765
~~~~
766766

branches/try2/mk/tests.mk

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,10 +386,6 @@ ifeq ($(CFG_GDB),)
386386
CTEST_DISABLE_debuginfo = "no gdb found"
387387
endif
388388

389-
ifeq ($(CFG_OSTYPE),apple-darwin)
390-
CTEST_DISABLE_debuginfo = "gdb on darwing needs root"
391-
endif
392-
393389
define DEF_CTEST_VARS
394390

395391
# All the per-stage build rules you might want to call from the

branches/try2/src/compiletest/runtest.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -225,15 +225,6 @@ actual:\n\
225225
}
226226

227227
fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
228-
// do not optimize debuginfo tests
229-
let config = match config.rustcflags {
230-
Some(flags) => config {
231-
rustcflags: Some(str::replace(flags, ~"-O", ~"")),
232-
.. config
233-
},
234-
None => config
235-
};
236-
237228
// compile test file (it shoud have 'compile-flags:-g' in the header)
238229
let mut ProcRes = compile_test(config, props, testfile);
239230
if ProcRes.status != 0 {
@@ -276,8 +267,8 @@ fn run_debuginfo_test(config: config, props: TestProps, testfile: &Path) {
276267
}
277268
}
278269
if i != num_check_lines {
279-
fatal_ProcRes(fmt!("line not found in debugger output: %s"
280-
props.check_lines[i]), ProcRes);
270+
fatal(fmt!("line not found in debugger output: %s",
271+
props.check_lines[i]));
281272
}
282273
}
283274
}

branches/try2/src/compiletest/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@ pub fn path_div() -> ~str { ~":" }
4646
pub fn path_div() -> ~str { ~";" }
4747

4848
pub fn logv(config: config, s: ~str) {
49-
debug!("%s", s);
49+
log(debug, s);
5050
if config.verbose { io::println(s); }
5151
}

branches/try2/src/etc/tidy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from licenseck import *
66

77
err=0
8-
cols=78
8+
cols=100
99

1010
# Be careful to support Python 2.4, 2.6, and 3.x here!
1111
config_proc=subprocess.Popen([ "git", "config", "core.autocrlf" ],

branches/try2/src/libcore/cast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub mod rusti {
1212
#[abi = "rust-intrinsic"]
1313
#[link_name = "rusti"]
1414
pub extern {
15-
fn forget<T>(+x: T);
15+
fn forget<T>(-x: T);
1616
fn reinterpret_cast<T, U>(&&e: T) -> U;
1717
}
1818
}

branches/try2/src/libcore/core.rc

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,14 @@ pub use clone::Clone;
216216
* more-verbosity. Error is the bottom level, default logging level is
217217
* warn-and-below.
218218
*/
219+
219220
/// The error log level
220-
#[cfg(stage0)]
221221
pub const error : u32 = 1_u32;
222222
/// The warning log level
223-
#[cfg(stage0)]
224223
pub const warn : u32 = 2_u32;
225224
/// The info log level
226-
#[cfg(stage0)]
227225
pub const info : u32 = 3_u32;
228226
/// The debug log level
229-
#[cfg(stage0)]
230227
pub const debug : u32 = 4_u32;
231228

232229

@@ -254,13 +251,9 @@ pub mod rt;
254251
// can be resolved within libcore.
255252
#[doc(hidden)] // FIXME #3538
256253
pub mod core {
257-
#[cfg(stage0)]
258254
pub const error : u32 = 1_u32;
259-
#[cfg(stage0)]
260255
pub const warn : u32 = 2_u32;
261-
#[cfg(stage0)]
262256
pub const info : u32 = 3_u32;
263-
#[cfg(stage0)]
264257
pub const debug : u32 = 4_u32;
265258

266259
pub use cmp;

branches/try2/src/libcore/io.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,7 @@ impl Writer for *libc::FILE {
683683
*self);
684684
if nout != len as size_t {
685685
error!("error writing buffer");
686-
error!("%s", os::last_os_error());
686+
log(error, os::last_os_error());
687687
fail!();
688688
}
689689
}
@@ -733,7 +733,7 @@ impl Writer for fd_t {
733733
let nout = libc::write(*self, vb, len as size_t);
734734
if nout < 0 as ssize_t {
735735
error!("error writing buffer");
736-
error!("%s", os::last_os_error());
736+
log(error, os::last_os_error());
737737
fail!();
738738
}
739739
count += nout as uint;
@@ -1288,6 +1288,7 @@ pub mod fsync {
12881288

12891289
#[cfg(test)]
12901290
mod tests {
1291+
use debug;
12911292
use i32;
12921293
use io::{BytesWriter, SeekCur, SeekEnd, SeekSet};
12931294
use io;
@@ -1300,10 +1301,10 @@ mod tests {
13001301
#[test]
13011302
fn test_simple() {
13021303
let tmpfile = &Path("tmp/lib-io-test-simple.tmp");
1303-
debug!(tmpfile);
1304+
log(debug, tmpfile);
13041305
let frood: ~str =
13051306
~"A hoopy frood who really knows where his towel is.";
1306-
debug!(copy frood);
1307+
log(debug, copy frood);
13071308
{
13081309
let out: io::Writer =
13091310
result::get(
@@ -1312,7 +1313,7 @@ mod tests {
13121313
}
13131314
let inp: io::Reader = result::get(&io::file_reader(tmpfile));
13141315
let frood2: ~str = inp.read_c_str();
1315-
debug!(copy frood2);
1316+
log(debug, copy frood2);
13161317
fail_unless!(frood == frood2);
13171318
}
13181319

branches/try2/src/libcore/libc.rs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,25 +1385,28 @@ pub mod funcs {
13851385
use libc::types::common::posix88::{DIR, dirent_t};
13861386
use libc::types::os::arch::c95::{c_char, c_int, c_long};
13871387

1388-
// NOTE: On OS X opendir and readdir have two versions,
1389-
// one for 32-bit kernelspace and one for 64.
1390-
// We should be linking to the 64-bit ones, called
1391-
// opendir$INODE64, etc. but for some reason rustc
1392-
// doesn't link it correctly on i686, so we're going
1393-
// through a C function that mysteriously does work.
1394-
pub unsafe fn opendir(dirname: *c_char) -> *DIR {
1395-
rust_opendir(dirname)
1396-
}
1397-
pub unsafe fn readdir(dirp: *DIR) -> *dirent_t {
1398-
rust_readdir(dirp)
1399-
}
1400-
1401-
extern {
1402-
unsafe fn rust_opendir(dirname: *c_char) -> *DIR;
1403-
unsafe fn rust_readdir(dirp: *DIR) -> *dirent_t;
1404-
}
1405-
14061388
pub extern {
1389+
// default bindings for opendir and readdir in
1390+
// non-macos unix
1391+
#[cfg(target_os = "linux")]
1392+
#[cfg(target_os = "android")]
1393+
#[cfg(target_os = "freebsd")]
1394+
unsafe fn opendir(dirname: *c_char) -> *DIR;
1395+
#[cfg(target_os = "linux")]
1396+
#[cfg(target_os = "android")]
1397+
#[cfg(target_os = "freebsd")]
1398+
unsafe fn readdir(dirp: *DIR) -> *dirent_t;
1399+
// on OSX (particularly when running with a
1400+
// 64bit kernel), we have an issue where there
1401+
// are separate bindings for opendir and readdir,
1402+
// which we have to explicitly link, as below.
1403+
#[cfg(target_os = "macos")]
1404+
#[link_name = "opendir$INODE64"]
1405+
unsafe fn opendir(dirname: *c_char) -> *DIR;
1406+
#[cfg(target_os = "macos")]
1407+
#[link_name = "readdir$INODE64"]
1408+
unsafe fn readdir(dirp: *DIR) -> *dirent_t;
1409+
14071410
unsafe fn closedir(dirp: *DIR) -> c_int;
14081411
unsafe fn rewinddir(dirp: *DIR);
14091412
unsafe fn seekdir(dirp: *DIR, loc: c_long);

0 commit comments

Comments
 (0)