Remove internal liblog
This commit deletes the internal liblog in favor of the implementation that
lives on crates.io. Similarly it's also setting a convention for adding crates
to the compiler. The main restriction right now is that we want compiler
implementation details to be unreachable from normal Rust code (e.g. requires a
feature), and by default everything in the sysroot is reachable via `extern
crate`.
The proposal here is to require that crates pulled in have these lines in their
`src/lib.rs`:
#![cfg_attr(rustbuild, feature(staged_api, rustc_private))]
#![cfg_attr(rustbuild, unstable(feature = "rustc_private", issue = "27812"))]
This'll mean that by default they're not using these attributes but when
compiled as part of the compiler they do a few things:
* Mark themselves as entirely unstable via the `staged_api` feature and the
`#![unstable]` attribute.
* Allow usage of other unstable crates via `feature(rustc_private)` which is
required if the crate relies on any other crates to compile (other than std).
This commit is contained in:
parent
90346eae18
commit
e341d603fe
38 changed files with 54 additions and 1194 deletions
|
|
@ -1,18 +0,0 @@
|
|||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
|
||||
pub fn foo<T>() {
|
||||
fn death() -> isize { panic!() }
|
||||
debug!("{}", (||{ death() })());
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags: -C debug-assertions=no
|
||||
// exec-env:RUST_LOG=conditional-debug-macro-off=4
|
||||
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub fn main() {
|
||||
// only panics if println! evaluates its argument.
|
||||
debug!("{:?}", { if true { panic!() } });
|
||||
}
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// compile-flags:-C debug-assertions=no
|
||||
// exec-env:RUST_LOG=logging-enabled-debug=debug
|
||||
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub fn main() {
|
||||
if log_enabled!(log::DEBUG) {
|
||||
panic!("what?! debugging?");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// exec-env:RUST_LOG=logging_enabled=info
|
||||
// ignore-emscripten: FIXME(#31622)
|
||||
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
pub fn main() {
|
||||
if log_enabled!(log::DEBUG) {
|
||||
panic!("what?! debugging?");
|
||||
}
|
||||
if !log_enabled!(log::INFO) {
|
||||
panic!("what?! no info?");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// aux-build:logging_right_crate.rs
|
||||
// exec-env:RUST_LOG=logging-right-crate=debug
|
||||
|
||||
// This is a test for issue #3046 to make sure that when we monomorphize a
|
||||
// function from one crate to another the right top-level logging name is
|
||||
// preserved.
|
||||
//
|
||||
// It used to be the case that if logging were turned on for this crate, all
|
||||
// monomorphized functions from other crates had logging turned on (their
|
||||
// logging module names were all incorrect). This test ensures that this no
|
||||
// longer happens by enabling logging for *this* crate and then invoking a
|
||||
// function in an external crate which will panic when logging is enabled.
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
extern crate logging_right_crate;
|
||||
|
||||
pub fn main() {
|
||||
// this function panicks if logging is turned on
|
||||
logging_right_crate::foo::<isize>();
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// ignore-windows
|
||||
// exec-env:RUST_LOG=debug
|
||||
// compile-flags:-C debug-assertions=y
|
||||
// ignore-emscripten: FIXME(#31622)
|
||||
|
||||
#![feature(rustc_private)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::process::Command;
|
||||
use std::env;
|
||||
use std::str;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
if args.len() > 1 && args[1] == "child" {
|
||||
debug!("foo");
|
||||
debug!("bar");
|
||||
return
|
||||
}
|
||||
|
||||
let p = Command::new(&args[0])
|
||||
.arg("child")
|
||||
.output().unwrap();
|
||||
assert!(p.status.success());
|
||||
let mut lines = str::from_utf8(&p.stderr).unwrap().lines();
|
||||
assert!(lines.next().unwrap().contains("foo"));
|
||||
assert!(lines.next().unwrap().contains("bar"));
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// exec-env:RUST_LOG=rust_log_filter/foo
|
||||
// ignore-emscripten no threads support
|
||||
|
||||
#![allow(unknown_features)]
|
||||
#![feature(box_syntax, std_misc, rustc_private)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate log;
|
||||
|
||||
use std::sync::mpsc::{channel, Sender, Receiver};
|
||||
use std::thread;
|
||||
|
||||
pub struct ChannelLogger {
|
||||
tx: Sender<String>
|
||||
}
|
||||
|
||||
impl ChannelLogger {
|
||||
pub fn new() -> (Box<ChannelLogger>, Receiver<String>) {
|
||||
let (tx, rx) = channel();
|
||||
(box ChannelLogger { tx: tx }, rx)
|
||||
}
|
||||
}
|
||||
|
||||
impl log::Logger for ChannelLogger {
|
||||
fn log(&mut self, record: &log::LogRecord) {
|
||||
self.tx.send(format!("{}", record.args)).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let (logger, rx) = ChannelLogger::new();
|
||||
|
||||
let t = thread::spawn(move|| {
|
||||
log::set_logger(logger);
|
||||
|
||||
info!("foo");
|
||||
info!("bar");
|
||||
info!("foo bar");
|
||||
info!("bar foo");
|
||||
});
|
||||
|
||||
assert_eq!(rx.recv().unwrap(), "foo");
|
||||
assert_eq!(rx.recv().unwrap(), "foo bar");
|
||||
assert_eq!(rx.recv().unwrap(), "bar foo");
|
||||
assert!(rx.recv().is_err());
|
||||
|
||||
t.join();
|
||||
}
|
||||
|
|
@ -8,8 +8,6 @@
|
|||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
// exec-env:RUST_LOG=conditional-debug-macro-on=4
|
||||
|
||||
pub fn main() {
|
||||
// exits early if println! evaluates its arguments, otherwise it
|
||||
// will hit the panic.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue