os: osx
osx_image: xcode8.2
install: &osx_install_sccache >
- travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-apple-darwin &&
+ travis_retry curl -o /usr/local/bin/sccache https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-apple-darwin &&
chmod +x /usr/local/bin/sccache &&
travis_retry curl -o /usr/local/bin/stamp https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-17-stamp-x86_64-apple-darwin &&
chmod +x /usr/local/bin/stamp
- set PATH=C:\Python27;%PATH%
# Download and install sccache
- - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-pc-windows-msvc
- - mv 2017-03-22-sccache-x86_64-pc-windows-msvc sccache.exe
+ - appveyor-retry appveyor DownloadFile https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-pc-windows-msvc
+ - mv 2017-03-24-sccache-x86_64-pc-windows-msvc sccache.exe
- set PATH=%PATH%;%CD%
# Download and install ninja
name = "compiletest"
version = "0.0.0"
dependencies = [
- "env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.23 (registry+https://github.com/rust-lang/crates.io-index)",
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-[[package]]
-name = "env_logger"
-version = "0.3.5"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
[[package]]
name = "env_logger"
version = "0.4.2"
name = "linkchecker"
version = "0.1.0"
-[[package]]
-name = "log"
-version = "0.0.0"
-
[[package]]
name = "log"
version = "0.3.7"
"arena 0.0.0",
"fmt_macros 0.0.0",
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_back 0.0.0",
"rustc_bitflags 0.0.0",
"rustc_const_math 0.0.0",
name = "rustc_back"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
"syntax 0.0.0",
]
version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
dependencies = [
"arena 0.0.0",
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_math 0.0.0",
name = "rustc_data_structures"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"serialize 0.0.0",
]
version = "0.0.0"
dependencies = [
"arena 0.0.0",
+ "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro_plugin 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"serialize 0.0.0",
name = "rustc_lint"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_eval 0.0.0",
version = "0.0.0"
dependencies = [
"flate 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro 0.0.0",
"rustc 0.0.0",
"rustc_back 0.0.0",
version = "0.0.0"
dependencies = [
"graphviz 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_bitflags 0.0.0",
"rustc_const_eval 0.0.0",
name = "rustc_passes"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_const_eval 0.0.0",
"rustc_const_math 0.0.0",
version = "0.0.0"
dependencies = [
"arena 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_errors 0.0.0",
"syntax 0.0.0",
name = "rustc_save_analysis"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-data 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rls-span 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
version = "0.0.0"
dependencies = [
"flate 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_bitflags 0.0.0",
dependencies = [
"arena 0.0.0",
"fmt_macros 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_eval 0.0.0",
dependencies = [
"arena 0.0.0",
"build_helper 0.1.0",
+ "env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"gcc 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_back 0.0.0",
"rustc_const_eval 0.0.0",
name = "syntax"
version = "0.0.0"
dependencies = [
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_bitflags 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
version = "0.0.0"
dependencies = [
"fmt_macros 0.0.0",
- "log 0.0.0",
+ "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
"proc_macro 0.0.0",
"rustc_errors 0.0.0",
"syntax 0.0.0",
"checksum clap 2.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "74a80f603221c9cd9aa27a28f52af452850051598537bb6b359c38a7d61e5cda"
"checksum cmake 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)" = "d18d68987ed4c516dcc3e7913659bfa4076f5182eea4a7e0038bb060953e76ac"
"checksum dtoa 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "80c8b71fd71146990a9742fc06dcbbde19161a267e0ad4e572c35162f4578c90"
-"checksum env_logger 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "15abd780e45b3ea4f76b4e9a26ff4843258dd8a3eed2775a0e7368c2e7936c2f"
"checksum env_logger 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e3856f1697098606fc6cb97a93de88ca3f3bc35bb878c725920e6e82ecf05e83"
"checksum filetime 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5363ab8e4139b8568a6237db5248646e5a8a2f89bd5ccb02092182b11fd3e922"
"checksum gcc 0.3.44 (registry+https://github.com/rust-lang/crates.io-index)" = "a32cd40070d7611ab76343dcb3204b2bb28c8a9450989a83a3d590248142f439"
RUN curl -O http://ftp.nl.debian.org/debian/dists/jessie/main/installer-armhf/current/images/device-tree/vexpress-v2p-ca15-tc1.dtb
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
pkg-config
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV TARGETS=arm-linux-androideabi
USER root
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV PATH=$PATH:/x-tools/arm-unknown-linux-gnueabi/bin
USER root
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV PATH=$PATH:/x-tools/aarch64-unknown-linux-gnueabi/bin
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV \
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV \
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV RUST_CONFIGURE_ARGS \
pkg-config
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
pkg-config
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
USER root
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV PATH=$PATH:/x-tools/powerpc-unknown-linux-gnu/bin
RUN ./build-powerpc64le-toolchain.sh
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV PATH=$PATH:/x-tools/powerpc64-unknown-linux-gnu/bin
USER root
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV PATH=$PATH:/x-tools/s390x-ibm-linux-gnu/bin:/x-tools/x86_64-unknown-netbsd/bin
ENTRYPOINT ["/rustroot/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV HOSTS=i686-unknown-linux-gnu
ENTRYPOINT ["/usr/bin/dumb-init", "--"]
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
ENV RUST_CONFIGURE_ARGS \
lib32stdc++6
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
pkg-config
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
pkg-config
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
xz-utils
RUN curl -o /usr/local/bin/sccache \
- https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-22-sccache-x86_64-unknown-linux-musl && \
+ https://s3.amazonaws.com/rust-lang-ci/rust-ci-mirror/2017-03-24-sccache-x86_64-unknown-linux-musl && \
chmod +x /usr/local/bin/sccache
RUN curl -OL https://github.com/Yelp/dumb-init/releases/download/v1.2.0/dumb-init_1.2.0_amd64.deb && \
+++ /dev/null
-[package]
-authors = ["The Rust Project Developers"]
-name = "log"
-version = "0.0.0"
-
-[lib]
-name = "log"
-path = "lib.rs"
-crate-type = ["dylib", "rlib"]
+++ /dev/null
-// 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.
-
-use std::ascii::AsciiExt;
-use std::cmp;
-
-#[derive(Debug, Clone)]
-pub struct LogDirective {
- pub name: Option<String>,
- pub level: u32,
-}
-
-pub const LOG_LEVEL_NAMES: [&'static str; 5] = ["ERROR", "WARN", "INFO", "DEBUG", "TRACE"];
-
-/// Parse an individual log level that is either a number or a symbolic log level
-fn parse_log_level(level: &str) -> Option<u32> {
- level.parse::<u32>()
- .ok()
- .or_else(|| {
- let pos = LOG_LEVEL_NAMES.iter().position(|&name| name.eq_ignore_ascii_case(level));
- pos.map(|p| p as u32 + 1)
- })
- .map(|p| cmp::min(p, ::MAX_LOG_LEVEL))
-}
-
-/// Parse a logging specification string (e.g: "crate1,crate2::mod3,crate3::x=1/foo")
-/// and return a vector with log directives.
-///
-/// Valid log levels are 0-255, with the most likely ones being 1-4 (defined in
-/// std::). Also supports string log levels of error, warn, info, and debug
-pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<String>) {
- let mut dirs = Vec::new();
-
- let mut parts = spec.split('/');
- let mods = parts.next();
- let filter = parts.next();
- if parts.next().is_some() {
- println!("warning: invalid logging spec '{}', ignoring it (too many '/'s)",
- spec);
- return (dirs, None);
- }
- if let Some(m) = mods {
- for s in m.split(',') {
- if s.is_empty() {
- continue;
- }
- let mut parts = s.split('=');
- let (log_level, name) =
- match (parts.next(), parts.next().map(|s| s.trim()), parts.next()) {
- (Some(part0), None, None) => {
- // if the single argument is a log-level string or number,
- // treat that as a global fallback
- match parse_log_level(part0) {
- Some(num) => (num, None),
- None => (::MAX_LOG_LEVEL, Some(part0)),
- }
- }
- (Some(part0), Some(""), None) => (::MAX_LOG_LEVEL, Some(part0)),
- (Some(part0), Some(part1), None) => {
- match parse_log_level(part1) {
- Some(num) => (num, Some(part0)),
- _ => {
- println!("warning: invalid logging spec '{}', ignoring it", part1);
- continue;
- }
- }
- }
- _ => {
- println!("warning: invalid logging spec '{}', ignoring it", s);
- continue;
- }
- };
- dirs.push(LogDirective {
- name: name.map(str::to_owned),
- level: log_level,
- });
- }
- }
-
- (dirs, filter.map(str::to_owned))
-}
-
-#[cfg(test)]
-mod tests {
- use super::parse_logging_spec;
-
- #[test]
- fn parse_logging_spec_valid() {
- let (dirs, filter) = parse_logging_spec("crate1::mod1=1,crate1::mod2,crate2=4");
- assert_eq!(dirs.len(), 3);
- assert_eq!(dirs[0].name, Some("crate1::mod1".to_owned()));
- assert_eq!(dirs[0].level, 1);
-
- assert_eq!(dirs[1].name, Some("crate1::mod2".to_owned()));
- assert_eq!(dirs[1].level, ::MAX_LOG_LEVEL);
-
- assert_eq!(dirs[2].name, Some("crate2".to_owned()));
- assert_eq!(dirs[2].level, 4);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_invalid_crate() {
- // test parse_logging_spec with multiple = in specification
- let (dirs, filter) = parse_logging_spec("crate1::mod1=1=2,crate2=4");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate2".to_owned()));
- assert_eq!(dirs[0].level, 4);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_invalid_log_level() {
- // test parse_logging_spec with 'noNumber' as log level
- let (dirs, filter) = parse_logging_spec("crate1::mod1=noNumber,crate2=4");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate2".to_owned()));
- assert_eq!(dirs[0].level, 4);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_string_log_level() {
- // test parse_logging_spec with 'warn' as log level
- let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2=warn");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate2".to_owned()));
- assert_eq!(dirs[0].level, ::WARN);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_empty_log_level() {
- // test parse_logging_spec with '' as log level
- let (dirs, filter) = parse_logging_spec("crate1::mod1=wrong,crate2=");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate2".to_owned()));
- assert_eq!(dirs[0].level, ::MAX_LOG_LEVEL);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_global() {
- // test parse_logging_spec with no crate
- let (dirs, filter) = parse_logging_spec("warn,crate2=4");
- assert_eq!(dirs.len(), 2);
- assert_eq!(dirs[0].name, None);
- assert_eq!(dirs[0].level, 2);
- assert_eq!(dirs[1].name, Some("crate2".to_owned()));
- assert_eq!(dirs[1].level, 4);
- assert!(filter.is_none());
- }
-
- #[test]
- fn parse_logging_spec_valid_filter() {
- let (dirs, filter) = parse_logging_spec("crate1::mod1=1,crate1::mod2,crate2=4/abc");
- assert_eq!(dirs.len(), 3);
- assert_eq!(dirs[0].name, Some("crate1::mod1".to_owned()));
- assert_eq!(dirs[0].level, 1);
-
- assert_eq!(dirs[1].name, Some("crate1::mod2".to_owned()));
- assert_eq!(dirs[1].level, ::MAX_LOG_LEVEL);
-
- assert_eq!(dirs[2].name, Some("crate2".to_owned()));
- assert_eq!(dirs[2].level, 4);
- assert!(filter.is_some() && filter.unwrap().to_owned() == "abc");
- }
-
- #[test]
- fn parse_logging_spec_invalid_crate_filter() {
- let (dirs, filter) = parse_logging_spec("crate1::mod1=1=2,crate2=4/a.c");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate2".to_owned()));
- assert_eq!(dirs[0].level, 4);
- assert!(filter.is_some() && filter.unwrap().to_owned() == "a.c");
- }
-
- #[test]
- fn parse_logging_spec_empty_with_filter() {
- let (dirs, filter) = parse_logging_spec("crate1/a*c");
- assert_eq!(dirs.len(), 1);
- assert_eq!(dirs[0].name, Some("crate1".to_owned()));
- assert_eq!(dirs[0].level, ::MAX_LOG_LEVEL);
- assert!(filter.is_some() && filter.unwrap().to_owned() == "a*c");
- }
-}
+++ /dev/null
-// 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.
-
-//! Utilities for program-wide and customizable logging
-//!
-//! # Examples
-//!
-//! ```
-//! # #![feature(rustc_private)]
-//! #[macro_use] extern crate log;
-//!
-//! fn main() {
-//! debug!("this is a debug {:?}", "message");
-//! error!("this is printed by default");
-//!
-//! if log_enabled!(log::INFO) {
-//! let x = 3 * 4; // expensive computation
-//! info!("the answer was: {:?}", x);
-//! }
-//! }
-//! ```
-//!
-//! Assumes the binary is `main`:
-//!
-//! ```{.bash}
-//! $ RUST_LOG=error ./main
-//! ERROR:main: this is printed by default
-//! ```
-//!
-//! ```{.bash}
-//! $ RUST_LOG=info ./main
-//! ERROR:main: this is printed by default
-//! INFO:main: the answer was: 12
-//! ```
-//!
-//! ```{.bash}
-//! $ RUST_LOG=debug ./main
-//! DEBUG:main: this is a debug message
-//! ERROR:main: this is printed by default
-//! INFO:main: the answer was: 12
-//! ```
-//!
-//! You can also set the log level on a per module basis:
-//!
-//! ```{.bash}
-//! $ RUST_LOG=main=info ./main
-//! ERROR:main: this is printed by default
-//! INFO:main: the answer was: 12
-//! ```
-//!
-//! And enable all logging:
-//!
-//! ```{.bash}
-//! $ RUST_LOG=main ./main
-//! DEBUG:main: this is a debug message
-//! ERROR:main: this is printed by default
-//! INFO:main: the answer was: 12
-//! ```
-//!
-//! # Logging Macros
-//!
-//! There are five macros that the logging subsystem uses:
-//!
-//! * `log!(level, ...)` - the generic logging macro, takes a level as a u32 and any
-//! related `format!` arguments
-//! * `debug!(...)` - a macro hard-wired to the log level of `DEBUG`
-//! * `info!(...)` - a macro hard-wired to the log level of `INFO`
-//! * `warn!(...)` - a macro hard-wired to the log level of `WARN`
-//! * `error!(...)` - a macro hard-wired to the log level of `ERROR`
-//!
-//! All of these macros use the same style of syntax as the `format!` syntax
-//! extension. Details about the syntax can be found in the documentation of
-//! `std::fmt` along with the Rust tutorial/manual.
-//!
-//! If you want to check at runtime if a given logging level is enabled (e.g. if the
-//! information you would want to log is expensive to produce), you can use the
-//! following macro:
-//!
-//! * `log_enabled!(level)` - returns true if logging of the given level is enabled
-//!
-//! # Enabling logging
-//!
-//! Log levels are controlled on a per-module basis, and by default all logging is
-//! disabled except for `error!` (a log level of 1). Logging is controlled via the
-//! `RUST_LOG` environment variable. The value of this environment variable is a
-//! comma-separated list of logging directives. A logging directive is of the form:
-//!
-//! ```text
-//! path::to::module=log_level
-//! ```
-//!
-//! The path to the module is rooted in the name of the crate it was compiled for,
-//! so if your program is contained in a file `hello.rs`, for example, to turn on
-//! logging for this file you would use a value of `RUST_LOG=hello`.
-//! Furthermore, this path is a prefix-search, so all modules nested in the
-//! specified module will also have logging enabled.
-//!
-//! The actual `log_level` is optional to specify. If omitted, all logging will be
-//! enabled. If specified, the it must be either a numeric in the range of 1-255, or
-//! it must be one of the strings `debug`, `error`, `info`, or `warn`. If a numeric
-//! is specified, then all logging less than or equal to that numeral is enabled.
-//! For example, if logging level 3 is active, error, warn, and info logs will be
-//! printed, but debug will be omitted.
-//!
-//! As the log level for a module is optional, the module to enable logging for is
-//! also optional. If only a `log_level` is provided, then the global log level for
-//! all modules is set to this value.
-//!
-//! Some examples of valid values of `RUST_LOG` are:
-//!
-//! * `hello` turns on all logging for the 'hello' module
-//! * `info` turns on all info logging
-//! * `hello=debug` turns on debug logging for 'hello'
-//! * `hello=3` turns on info logging for 'hello'
-//! * `hello,std::option` turns on hello, and std's option logging
-//! * `error,hello=warn` turn on global error logging and also warn for hello
-//!
-//! # Filtering results
-//!
-//! A RUST_LOG directive may include a string filter. The syntax is to append
-//! `/` followed by a string. Each message is checked against the string and is
-//! only logged if it contains the string. Note that the matching is done after
-//! formatting the log string but before adding any logging meta-data. There is
-//! a single filter for all modules.
-//!
-//! Some examples:
-//!
-//! * `hello/foo` turns on all logging for the 'hello' module where the log message
-//! includes 'foo'.
-//! * `info/f.o` turns on all info logging where the log message includes 'foo',
-//! 'f1o', 'fao', etc.
-//! * `hello=debug/foo*foo` turns on debug logging for 'hello' where the log
-//! message includes 'foofoo' or 'fofoo' or 'fooooooofoo', etc.
-//! * `error,hello=warn/[0-9] scopes` turn on global error logging and also warn for
-//! hello. In both cases the log message must include a single digit number
-//! followed by 'scopes'
-//!
-//! # Performance and Side Effects
-//!
-//! Each of these macros will expand to code similar to:
-//!
-//! ```rust,ignore
-//! if log_level <= my_module_log_level() {
-//! ::log::log(log_level, format!(...));
-//! }
-//! ```
-//!
-//! What this means is that each of these macros are very cheap at runtime if
-//! they're turned off (just a load and an integer comparison). This also means that
-//! if logging is disabled, none of the components of the log will be executed.
-
-#![crate_name = "log"]
-#![unstable(feature = "rustc_private",
- reason = "use the crates.io `log` library instead",
- issue = "27812")]
-#![crate_type = "rlib"]
-#![crate_type = "dylib"]
-#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
- html_favicon_url = "https://doc.rust-lang.org/favicon.ico",
- html_root_url = "https://doc.rust-lang.org/nightly/",
- html_playground_url = "https://play.rust-lang.org/",
- test(attr(deny(warnings))))]
-#![deny(missing_docs)]
-#![deny(warnings)]
-
-#![feature(staged_api)]
-
-use std::cell::RefCell;
-use std::fmt;
-use std::io::{self, Stderr};
-use std::io::prelude::*;
-use std::mem;
-use std::env;
-use std::slice;
-use std::sync::{Mutex, ONCE_INIT, Once};
-
-use directive::LOG_LEVEL_NAMES;
-
-#[macro_use]
-pub mod macros;
-
-mod directive;
-
-/// Maximum logging level of a module that can be specified. Common logging
-/// levels are found in the DEBUG/INFO/WARN/ERROR constants.
-pub const MAX_LOG_LEVEL: u32 = 255;
-
-/// The default logging level of a crate if no other is specified.
-const DEFAULT_LOG_LEVEL: u32 = 1;
-
-static mut LOCK: *mut Mutex<(Vec<directive::LogDirective>, Option<String>)> = 0 as *mut _;
-
-/// An unsafe constant that is the maximum logging level of any module
-/// specified. This is the first line of defense to determining whether a
-/// logging statement should be run.
-static mut LOG_LEVEL: u32 = MAX_LOG_LEVEL;
-
-/// Debug log level
-pub const DEBUG: u32 = 4;
-/// Info log level
-pub const INFO: u32 = 3;
-/// Warn log level
-pub const WARN: u32 = 2;
-/// Error log level
-pub const ERROR: u32 = 1;
-
-thread_local! {
- static LOCAL_LOGGER: RefCell<Option<Box<Logger + Send>>> = {
- RefCell::new(None)
- }
-}
-
-/// A trait used to represent an interface to a thread-local logger. Each thread
-/// can have its own custom logger which can respond to logging messages
-/// however it likes.
-pub trait Logger {
- /// Logs a single message described by the `record`.
- fn log(&mut self, record: &LogRecord);
-}
-
-struct DefaultLogger {
- handle: Stderr,
-}
-
-/// Wraps the log level with fmt implementations.
-#[derive(Copy, Clone, PartialEq, PartialOrd, Debug)]
-pub struct LogLevel(pub u32);
-
-impl fmt::Display for LogLevel {
- fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
- let LogLevel(level) = *self;
- match LOG_LEVEL_NAMES.get(level as usize - 1) {
- Some(ref name) => fmt::Display::fmt(name, fmt),
- None => fmt::Display::fmt(&level, fmt),
- }
- }
-}
-
-impl Logger for DefaultLogger {
- fn log(&mut self, record: &LogRecord) {
- match writeln!(&mut self.handle,
- "{}:{}: {}",
- record.level,
- record.module_path,
- record.args) {
- Err(e) => panic!("failed to log: {:?}", e),
- Ok(()) => {}
- }
- }
-}
-
-impl Drop for DefaultLogger {
- fn drop(&mut self) {
- // FIXME(#12628): is panicking the right thing to do?
- match self.handle.flush() {
- Err(e) => panic!("failed to flush a logger: {:?}", e),
- Ok(()) => {}
- }
- }
-}
-
-/// This function is called directly by the compiler when using the logging
-/// macros. This function does not take into account whether the log level
-/// specified is active or not, it will always log something if this method is
-/// called.
-///
-/// It is not recommended to call this function directly, rather it should be
-/// invoked through the logging family of macros.
-#[doc(hidden)]
-pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
- // Test the literal string from args against the current filter, if there
- // is one.
- unsafe {
- let filter = (*LOCK).lock().unwrap();
- if let Some(ref filter) = filter.1 {
- if !args.to_string().contains(filter) {
- return;
- }
- }
- }
-
- // Completely remove the local logger from TLS in case anyone attempts to
- // frob the slot while we're doing the logging. This will destroy any logger
- // set during logging.
- let logger = LOCAL_LOGGER.with(|s| s.borrow_mut().take());
- let mut logger = logger.unwrap_or_else(|| Box::new(DefaultLogger { handle: io::stderr() }));
- logger.log(&LogRecord {
- level: LogLevel(level),
- args: args,
- file: loc.file,
- module_path: loc.module_path,
- line: loc.line,
- });
- set_logger(logger);
-}
-
-/// Getter for the global log level. This is a function so that it can be called
-/// safely
-#[doc(hidden)]
-#[inline(always)]
-pub fn log_level() -> u32 {
- unsafe { LOG_LEVEL }
-}
-
-/// Replaces the thread-local logger with the specified logger, returning the old
-/// logger.
-pub fn set_logger(logger: Box<Logger + Send>) -> Option<Box<Logger + Send>> {
- LOCAL_LOGGER.with(|slot| mem::replace(&mut *slot.borrow_mut(), Some(logger)))
-}
-
-/// A LogRecord is created by the logging macros, and passed as the only
-/// argument to Loggers.
-#[derive(Debug)]
-pub struct LogRecord<'a> {
- /// The module path of where the LogRecord originated.
- pub module_path: &'a str,
-
- /// The LogLevel of this record.
- pub level: LogLevel,
-
- /// The arguments from the log line.
- pub args: fmt::Arguments<'a>,
-
- /// The file of where the LogRecord originated.
- pub file: &'a str,
-
- /// The line number of where the LogRecord originated.
- pub line: u32,
-}
-
-#[doc(hidden)]
-#[derive(Copy, Clone)]
-pub struct LogLocation {
- pub module_path: &'static str,
- pub file: &'static str,
- pub line: u32,
-}
-
-/// Tests whether a given module's name is enabled for a particular level of
-/// logging. This is the second layer of defense about determining whether a
-/// module's log statement should be emitted or not.
-#[doc(hidden)]
-pub fn mod_enabled(level: u32, module: &str) -> bool {
- static INIT: Once = ONCE_INIT;
- INIT.call_once(init);
-
- // It's possible for many threads are in this function, only one of them
- // will perform the global initialization, but all of them will need to check
- // again to whether they should really be here or not. Hence, despite this
- // check being expanded manually in the logging macro, this function checks
- // the log level again.
- if level > unsafe { LOG_LEVEL } {
- return false;
- }
-
- // This assertion should never get tripped unless we're in an at_exit
- // handler after logging has been torn down and a logging attempt was made.
-
- unsafe {
- let directives = (*LOCK).lock().unwrap();
- enabled(level, module, directives.0.iter())
- }
-}
-
-fn enabled(level: u32, module: &str, iter: slice::Iter<directive::LogDirective>) -> bool {
- // Search for the longest match, the vector is assumed to be pre-sorted.
- for directive in iter.rev() {
- match directive.name {
- Some(ref name) if !module.starts_with(&name[..]) => {}
- Some(..) | None => return level <= directive.level,
- }
- }
- level <= DEFAULT_LOG_LEVEL
-}
-
-/// Initialize logging for the current process.
-///
-/// This is not threadsafe at all, so initialization is performed through a
-/// `Once` primitive (and this function is called from that primitive).
-fn init() {
- let (mut directives, filter) = match env::var("RUST_LOG") {
- Ok(spec) => directive::parse_logging_spec(&spec[..]),
- Err(..) => (Vec::new(), None),
- };
-
- // Sort the provided directives by length of their name, this allows a
- // little more efficient lookup at runtime.
- directives.sort_by(|a, b| {
- let alen = a.name.as_ref().map(|a| a.len()).unwrap_or(0);
- let blen = b.name.as_ref().map(|b| b.len()).unwrap_or(0);
- alen.cmp(&blen)
- });
-
- let max_level = {
- let max = directives.iter().max_by_key(|d| d.level);
- max.map(|d| d.level).unwrap_or(DEFAULT_LOG_LEVEL)
- };
-
- unsafe {
- LOG_LEVEL = max_level;
-
- assert!(LOCK.is_null());
- LOCK = Box::into_raw(Box::new(Mutex::new((directives, filter))));
- }
-}
-
-#[cfg(test)]
-mod tests {
- use super::enabled;
- use directive::LogDirective;
-
- #[test]
- fn match_full_path() {
- let dirs = [LogDirective {
- name: Some("crate2".to_string()),
- level: 3,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 2,
- }];
- assert!(enabled(2, "crate1::mod1", dirs.iter()));
- assert!(!enabled(3, "crate1::mod1", dirs.iter()));
- assert!(enabled(3, "crate2", dirs.iter()));
- assert!(!enabled(4, "crate2", dirs.iter()));
- }
-
- #[test]
- fn no_match() {
- let dirs = [LogDirective {
- name: Some("crate2".to_string()),
- level: 3,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 2,
- }];
- assert!(!enabled(2, "crate3", dirs.iter()));
- }
-
- #[test]
- fn match_beginning() {
- let dirs = [LogDirective {
- name: Some("crate2".to_string()),
- level: 3,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 2,
- }];
- assert!(enabled(3, "crate2::mod1", dirs.iter()));
- }
-
- #[test]
- fn match_beginning_longest_match() {
- let dirs = [LogDirective {
- name: Some("crate2".to_string()),
- level: 3,
- },
- LogDirective {
- name: Some("crate2::mod".to_string()),
- level: 4,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 2,
- }];
- assert!(enabled(4, "crate2::mod1", dirs.iter()));
- assert!(!enabled(4, "crate2", dirs.iter()));
- }
-
- #[test]
- fn match_default() {
- let dirs = [LogDirective {
- name: None,
- level: 3,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 2,
- }];
- assert!(enabled(2, "crate1::mod1", dirs.iter()));
- assert!(enabled(3, "crate2::mod2", dirs.iter()));
- }
-
- #[test]
- fn zero_level() {
- let dirs = [LogDirective {
- name: None,
- level: 3,
- },
- LogDirective {
- name: Some("crate1::mod1".to_string()),
- level: 0,
- }];
- assert!(!enabled(1, "crate1::mod1", dirs.iter()));
- assert!(enabled(3, "crate2::mod2", dirs.iter()));
- }
-}
+++ /dev/null
-// 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.
-
-//! Logging macros
-
-/// The standard logging macro
-///
-/// This macro will generically log over a provided level (of type u32) with a
-/// format!-based argument list. See documentation in `std::fmt` for details on
-/// how to use the syntax.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// fn main() {
-/// log!(log::WARN, "this is a warning {}", "message");
-/// log!(log::DEBUG, "this is a debug message");
-/// log!(6, "this is a custom logging level: {level}", level=6);
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=warn ./main
-/// WARN:main: this is a warning message
-/// ```
-///
-/// ```{.bash}
-/// $ RUST_LOG=debug ./main
-/// DEBUG:main: this is a debug message
-/// WARN:main: this is a warning message
-/// ```
-///
-/// ```{.bash}
-/// $ RUST_LOG=6 ./main
-/// DEBUG:main: this is a debug message
-/// WARN:main: this is a warning message
-/// 6:main: this is a custom logging level: 6
-/// ```
-#[macro_export]
-macro_rules! log {
- ($lvl:expr, $($arg:tt)+) => ({
- static LOC: ::log::LogLocation = ::log::LogLocation {
- line: line!(),
- file: file!(),
- module_path: module_path!(),
- };
- let lvl = $lvl;
- if log_enabled!(lvl) {
- ::log::log(lvl, &LOC, format_args!($($arg)+))
- }
- })
-}
-
-/// A convenience macro for logging at the error log level.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// fn main() {
-/// let error = 3;
-/// error!("the build has failed with error code: {}", error);
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=error ./main
-/// ERROR:main: the build has failed with error code: 3
-/// ```
-///
-#[macro_export]
-macro_rules! error {
- ($($arg:tt)*) => (log!(::log::ERROR, $($arg)*))
-}
-
-/// A convenience macro for logging at the warning log level.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// fn main() {
-/// let code = 3;
-/// warn!("you may like to know that a process exited with: {}", code);
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=warn ./main
-/// WARN:main: you may like to know that a process exited with: 3
-/// ```
-#[macro_export]
-macro_rules! warn {
- ($($arg:tt)*) => (log!(::log::WARN, $($arg)*))
-}
-
-/// A convenience macro for logging at the info log level.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// fn main() {
-/// let ret = 3;
-/// info!("this function is about to return: {}", ret);
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=info ./main
-/// INFO:main: this function is about to return: 3
-/// ```
-#[macro_export]
-macro_rules! info {
- ($($arg:tt)*) => (log!(::log::INFO, $($arg)*))
-}
-
-/// A convenience macro for logging at the debug log level. This macro will
-/// be omitted at compile time in an optimized build unless `-C debug-assertions`
-/// is passed to the compiler.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// fn main() {
-/// debug!("x = {x}, y = {y}", x=10, y=20);
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=debug ./main
-/// DEBUG:main: x = 10, y = 20
-/// ```
-#[macro_export]
-macro_rules! debug {
- ($($arg:tt)*) => (if cfg!(debug_assertions) { log!(::log::DEBUG, $($arg)*) })
-}
-
-/// A macro to test whether a log level is enabled for the current module.
-///
-/// # Examples
-///
-/// ```
-/// # #![feature(rustc_private)]
-/// #[macro_use] extern crate log;
-///
-/// struct Point { x: i32, y: i32 }
-/// fn some_expensive_computation() -> Point { Point { x: 1, y: 2 } }
-///
-/// fn main() {
-/// if log_enabled!(log::DEBUG) {
-/// let x = some_expensive_computation();
-/// debug!("x.x = {}, x.y = {}", x.x, x.y);
-/// }
-/// }
-/// ```
-///
-/// Assumes the binary is `main`:
-///
-/// ```{.bash}
-/// $ RUST_LOG=error ./main
-/// ```
-///
-/// ```{.bash}
-/// $ RUST_LOG=debug ./main
-/// DEBUG:main: x.x = 1, x.y = 2
-/// ```
-#[macro_export]
-macro_rules! log_enabled {
- ($lvl:expr) => ({
- let lvl = $lvl;
- (lvl != ::log::DEBUG || cfg!(debug_assertions)) &&
- lvl <= ::log::log_level() &&
- ::log::mod_enabled(lvl, module_path!())
- })
-}
arena = { path = "../libarena" }
fmt_macros = { path = "../libfmt_macros" }
graphviz = { path = "../libgraphviz" }
-log = { path = "../liblog" }
+log = "0.3"
rustc_back = { path = "../librustc_back" }
rustc_bitflags = { path = "../librustc_bitflags" }
rustc_const_math = { path = "../librustc_const_math" }
intravisit::walk_crate(&mut collector, &forest.krate);
let map = collector.map;
- if log_enabled!(::log::DEBUG) {
+ if log_enabled!(::log::LogLevel::Debug) {
// This only makes sense for ordered stores; note the
// enumerate to count the number of entries.
let (entries_less_1, _) = map.iter().filter(|&x| {
} else {
// for local crates, check whether type info is
// available; typeck might not have completed yet
- self.maps.impl_trait_ref.borrow().contains_key(&impl_def_id)
+ self.maps.impl_trait_ref.borrow().contains_key(&impl_def_id) &&
+ self.maps.ty.borrow().contains_key(&impl_def_id)
};
if !use_types {
[dependencies]
syntax = { path = "../libsyntax" }
serialize = { path = "../libserialize" }
-log = { path = "../liblog" }
+log = "0.3"
[features]
jemalloc = []
test = false
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
graphviz = { path = "../libgraphviz" }
[dependencies]
arena = { path = "../libarena" }
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_math = { path = "../librustc_const_math" }
crate-type = ["dylib"]
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
serialize = { path = "../libserialize" }
[dependencies]
arena = { path = "../libarena" }
graphviz = { path = "../libgraphviz" }
-log = { path = "../liblog" }
+log = { version = "0.3", features = ["release_max_level_info"] }
+env_logger = { version = "0.4", default-features = false }
proc_macro_plugin = { path = "../libproc_macro_plugin" }
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
result?;
- if log_enabled!(::log::INFO) {
+ if log_enabled!(::log::LogLevel::Info) {
println!("Pre-trans");
tcx.print_debug_stats();
}
let trans = phase_4_translate_to_llvm(tcx, analysis, &incremental_hashes_map);
- if log_enabled!(::log::INFO) {
+ if log_enabled!(::log::LogLevel::Info) {
println!("Post-trans");
tcx.print_debug_stats();
}
extern crate arena;
extern crate getopts;
extern crate graphviz;
+extern crate env_logger;
extern crate libc;
extern crate rustc;
extern crate rustc_back;
}
pub fn main() {
+ env_logger::init().unwrap();
let result = run(|| run_compiler(&env::args().collect::<Vec<_>>(),
&mut RustcDefaultCalls,
None,
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
serialize = { path = "../libserialize" }
-log = { path = "../liblog" }
+log = "0.3"
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
test = false
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_eval = { path = "../librustc_const_eval" }
[dependencies]
flate = { path = "../libflate" }
-log = { path = "../liblog" }
+log = "0.3"
proc_macro = { path = "../libproc_macro" }
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
self.inject_allocator_crate();
self.inject_panic_runtime(krate);
- if log_enabled!(log::INFO) {
+ if log_enabled!(log::LogLevel::Info) {
dump_crates(&self.cstore);
}
[dependencies]
graphviz = { path = "../libgraphviz" }
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_const_eval = { path = "../librustc_const_eval" }
rustc_const_math = { path = "../librustc_const_math" }
crate-type = ["dylib"]
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_const_eval = { path = "../librustc_const_eval" }
rustc_const_math = { path = "../librustc_const_math" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
-rustc_errors = { path = "../librustc_errors" }
\ No newline at end of file
+rustc_errors = { path = "../librustc_errors" }
test = false
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
syntax = { path = "../libsyntax" }
rustc = { path = "../librustc" }
arena = { path = "../libarena" }
binding: &'a NameBinding<'a>,
span: Span,
allow_shadowing: bool) {
- if self.builtin_macros.insert(name, binding).is_some() && !allow_shadowing {
+ if self.global_macros.insert(name, binding).is_some() && !allow_shadowing {
let msg = format!("`{}` is already in scope", name);
let note =
"macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)";
use std::rc::Rc;
use resolve_imports::{ImportDirective, ImportDirectiveSubclass, NameResolution, ImportResolver};
-use macros::{InvocationData, LegacyBinding, LegacyScope};
+use macros::{InvocationData, LegacyBinding, LegacyScope, MacroBinding};
// NB: This module needs to be declared first so diagnostics are
// registered before they are used.
crate_loader: &'a mut CrateLoader,
macro_names: FxHashSet<Name>,
- builtin_macros: FxHashMap<Name, &'a NameBinding<'a>>,
+ global_macros: FxHashMap<Name, &'a NameBinding<'a>>,
lexical_macro_resolutions: Vec<(Name, &'a Cell<LegacyScope<'a>>)>,
macro_map: FxHashMap<DefId, Rc<SyntaxExtension>>,
macro_defs: FxHashMap<Mark, DefId>,
crate_loader: crate_loader,
macro_names: FxHashSet(),
- builtin_macros: FxHashMap(),
+ global_macros: FxHashMap(),
lexical_macro_resolutions: Vec::new(),
macro_map: FxHashMap(),
macro_exports: Vec::new(),
};
}
}
- let is_builtin = self.builtin_macros.get(&path[0].name).cloned()
+ let is_global = self.global_macros.get(&path[0].name).cloned()
.map(|binding| binding.get_macro(self).kind() == MacroKind::Bang).unwrap_or(false);
- if primary_ns != MacroNS && (is_builtin || self.macro_names.contains(&path[0].name)) {
+ if primary_ns != MacroNS && (is_global || self.macro_names.contains(&path[0].name)) {
// Return some dummy definition, it's enough for error reporting.
return Some(
PathResolution::new(Def::Macro(DefId::local(CRATE_DEF_INDEX), MacroKind::Bang))
self.resolve_ident_in_module(module, ident, ns, false, record_used)
} else if opt_ns == Some(MacroNS) {
self.resolve_lexical_macro_path_segment(ident, ns, record_used)
+ .map(MacroBinding::binding)
} else {
match self.resolve_ident_in_lexical_scope(ident, ns, record_used) {
Some(LexicalScopeBinding::Item(binding)) => Ok(binding),
};
let msg1 = format!("`{}` could refer to the name {} here", name, participle(b1));
let msg2 = format!("`{}` could also refer to the name {} here", name, participle(b2));
- let note = if !lexical && b1.is_glob_import() {
+ let note = if b1.expansion == Mark::root() || !lexical && b1.is_glob_import() {
format!("consider adding an explicit import of `{}` to disambiguate", name)
} else if let Def::Macro(..) = b1.def() {
format!("macro-expanded {} do not shadow",
let msg = format!("`{}` is ambiguous", name);
self.session.add_lint(lint::builtin::LEGACY_IMPORTS, id, span, msg);
} else {
- self.session.struct_span_err(span, &format!("`{}` is ambiguous", name))
- .span_note(b1.span, &msg1)
- .span_note(b2.span, &msg2)
- .note(¬e)
- .emit();
+ let mut err =
+ self.session.struct_span_err(span, &format!("`{}` is ambiguous", name));
+ err.span_note(b1.span, &msg1);
+ match b2.def() {
+ Def::Macro(..) if b2.span == DUMMY_SP =>
+ err.note(&format!("`{}` is also a builtin macro", name)),
+ _ => err.span_note(b2.span, &msg2),
+ };
+ err.note(¬e).emit();
}
}
if self.proc_macro_enabled { return; }
for attr in attrs {
- let name = unwrap_or!(attr.name(), continue);
- let maybe_binding = self.builtin_macros.get(&name).cloned().or_else(|| {
- let ident = Ident::with_empty_ctxt(name);
- self.resolve_lexical_macro_path_segment(ident, MacroNS, None).ok()
- });
-
- if let Some(binding) = maybe_binding {
- if let SyntaxExtension::AttrProcMacro(..) = *binding.get_macro(self) {
+ if attr.path.segments.len() > 1 {
+ continue
+ }
+ let ident = attr.path.segments[0].identifier;
+ let result = self.resolve_lexical_macro_path_segment(ident, MacroNS, None);
+ if let Ok(binding) = result {
+ if let SyntaxExtension::AttrProcMacro(..) = *binding.binding().get_macro(self) {
attr::mark_known(attr);
let msg = "attribute procedural macros are experimental";
feature_err(&self.session.parse_sess, feature,
attr.span, GateIssue::Language, msg)
- .span_note(binding.span, "procedural macro imported here")
+ .span_note(binding.span(), "procedural macro imported here")
.emit();
}
}
pub span: Span,
}
+#[derive(Copy, Clone)]
pub enum MacroBinding<'a> {
Legacy(&'a LegacyBinding<'a>),
+ Global(&'a NameBinding<'a>),
Modern(&'a NameBinding<'a>),
}
+impl<'a> MacroBinding<'a> {
+ pub fn span(self) -> Span {
+ match self {
+ MacroBinding::Legacy(binding) => binding.span,
+ MacroBinding::Global(binding) | MacroBinding::Modern(binding) => binding.span,
+ }
+ }
+
+ pub fn binding(self) -> &'a NameBinding<'a> {
+ match self {
+ MacroBinding::Global(binding) | MacroBinding::Modern(binding) => binding,
+ MacroBinding::Legacy(_) => panic!("unexpected MacroBinding::Legacy"),
+ }
+ }
+}
+
impl<'a> base::Resolver for Resolver<'a> {
fn next_node_id(&mut self) -> ast::NodeId {
self.session.next_node_id()
vis: ty::Visibility::Invisible,
expansion: Mark::root(),
});
- self.builtin_macros.insert(ident.name, binding);
+ self.global_macros.insert(ident.name, binding);
}
fn resolve_imports(&mut self) {
attr::mark_known(&attrs[i]);
}
- match self.builtin_macros.get(&name).cloned() {
+ match self.global_macros.get(&name).cloned() {
Some(binding) => match *binding.get_macro(self) {
MultiModifier(..) | MultiDecorator(..) | SyntaxExtension::AttrProcMacro(..) => {
return Some(attrs.remove(i))
}
let trait_name = traits[j].segments[0].identifier.name;
let legacy_name = Symbol::intern(&format!("derive_{}", trait_name));
- if !self.builtin_macros.contains_key(&legacy_name) {
+ if !self.global_macros.contains_key(&legacy_name) {
continue
}
let span = traits.remove(j).span;
}
let name = path[0].name;
- let result = match self.resolve_legacy_scope(&invocation.legacy_scope, name, false) {
- Some(MacroBinding::Legacy(binding)) => Ok(Def::Macro(binding.def_id, MacroKind::Bang)),
- Some(MacroBinding::Modern(binding)) => Ok(binding.def_ignoring_ambiguity()),
- None => match self.resolve_lexical_macro_path_segment(path[0], MacroNS, None) {
- Ok(binding) => Ok(binding.def_ignoring_ambiguity()),
- Err(Determinacy::Undetermined) if !force =>
- return Err(Determinacy::Undetermined),
+ let legacy_resolution = self.resolve_legacy_scope(&invocation.legacy_scope, name, false);
+ let result = if let Some(MacroBinding::Legacy(binding)) = legacy_resolution {
+ Ok(Def::Macro(binding.def_id, MacroKind::Bang))
+ } else {
+ match self.resolve_lexical_macro_path_segment(path[0], MacroNS, None) {
+ Ok(binding) => Ok(binding.binding().def_ignoring_ambiguity()),
+ Err(Determinacy::Undetermined) if !force => return Err(Determinacy::Undetermined),
Err(_) => {
self.found_unresolved_macro = true;
Err(Determinacy::Determined)
}
- },
+ }
};
self.current_module.legacy_macro_resolutions.borrow_mut()
ident: Ident,
ns: Namespace,
record_used: Option<Span>)
- -> Result<&'a NameBinding<'a>, Determinacy> {
- let mut module = self.current_module;
- let mut potential_expanded_shadower: Option<&NameBinding> = None;
+ -> Result<MacroBinding<'a>, Determinacy> {
+ let mut module = Some(self.current_module);
+ let mut potential_illegal_shadower = Err(Determinacy::Determined);
+ let determinacy =
+ if record_used.is_some() { Determinacy::Determined } else { Determinacy::Undetermined };
loop {
- // Since expanded macros may not shadow the lexical scope (enforced below),
- // we can ignore unresolved invocations (indicated by the penultimate argument).
- match self.resolve_ident_in_module(module, ident, ns, true, record_used) {
+ let result = if let Some(module) = module {
+ // Since expanded macros may not shadow the lexical scope and
+ // globs may not shadow global macros (both enforced below),
+ // we resolve with restricted shadowing (indicated by the penultimate argument).
+ self.resolve_ident_in_module(module, ident, ns, true, record_used)
+ .map(MacroBinding::Modern)
+ } else {
+ self.global_macros.get(&ident.name).cloned().ok_or(determinacy)
+ .map(MacroBinding::Global)
+ };
+
+ match result.map(MacroBinding::binding) {
Ok(binding) => {
let span = match record_used {
Some(span) => span,
- None => return Ok(binding),
+ None => return result,
};
- match potential_expanded_shadower {
- Some(shadower) if shadower.def() != binding.def() => {
+ if let Ok(MacroBinding::Modern(shadower)) = potential_illegal_shadower {
+ if shadower.def() != binding.def() {
let name = ident.name;
self.ambiguity_errors.push(AmbiguityError {
span: span, name: name, b1: shadower, b2: binding, lexical: true,
legacy: false,
});
- return Ok(shadower);
+ return potential_illegal_shadower;
}
- _ if binding.expansion == Mark::root() => return Ok(binding),
- _ => potential_expanded_shadower = Some(binding),
+ }
+ if binding.expansion != Mark::root() ||
+ (binding.is_glob_import() && module.unwrap().def().is_some()) {
+ potential_illegal_shadower = result;
+ } else {
+ return result;
}
},
Err(Determinacy::Undetermined) => return Err(Determinacy::Undetermined),
Err(Determinacy::Determined) => {}
}
- match module.kind {
- ModuleKind::Block(..) => module = module.parent.unwrap(),
- ModuleKind::Def(..) => return match potential_expanded_shadower {
- Some(binding) => Ok(binding),
- None if record_used.is_some() => Err(Determinacy::Determined),
- None => Err(Determinacy::Undetermined),
+ module = match module {
+ Some(module) => match module.kind {
+ ModuleKind::Block(..) => module.parent,
+ ModuleKind::Def(..) => None,
},
+ None => return potential_illegal_shadower,
}
}
}
let binding = if let Some(binding) = binding {
MacroBinding::Legacy(binding)
- } else if let Some(binding) = self.builtin_macros.get(&name).cloned() {
+ } else if let Some(binding) = self.global_macros.get(&name).cloned() {
if !self.use_extern_macros {
self.record_use(Ident::with_empty_ctxt(name), MacroNS, binding, DUMMY_SP);
}
- MacroBinding::Modern(binding)
+ MacroBinding::Global(binding)
} else {
return None;
};
let legacy_resolution = self.resolve_legacy_scope(legacy_scope, ident.name, true);
let resolution = self.resolve_lexical_macro_path_segment(ident, MacroNS, Some(span));
match (legacy_resolution, resolution) {
- (Some(legacy_resolution), Ok(resolution)) => {
- let (legacy_span, participle) = match legacy_resolution {
- MacroBinding::Modern(binding)
- if binding.def() == resolution.def() => continue,
- MacroBinding::Modern(binding) => (binding.span, "imported"),
- MacroBinding::Legacy(binding) => (binding.span, "defined"),
- };
- let msg1 = format!("`{}` could refer to the macro {} here", ident, participle);
+ (Some(MacroBinding::Legacy(legacy_binding)), Ok(MacroBinding::Modern(binding))) => {
+ let msg1 = format!("`{}` could refer to the macro defined here", ident);
let msg2 = format!("`{}` could also refer to the macro imported here", ident);
self.session.struct_span_err(span, &format!("`{}` is ambiguous", ident))
- .span_note(legacy_span, &msg1)
- .span_note(resolution.span, &msg2)
+ .span_note(legacy_binding.span, &msg1)
+ .span_note(binding.span, &msg2)
.emit();
},
- (Some(MacroBinding::Modern(binding)), Err(_)) => {
+ (Some(MacroBinding::Global(binding)), Ok(MacroBinding::Global(_))) => {
self.record_use(ident, MacroNS, binding, span);
self.err_if_macro_use_proc_macro(ident.name, span, binding);
},
find_best_match_for_name(self.macro_names.iter(), name, None)
} else {
None
- // Then check builtin macros.
+ // Then check global macros.
}.or_else(|| {
// FIXME: get_macro needs an &mut Resolver, can we do it without cloning?
- let builtin_macros = self.builtin_macros.clone();
- let names = builtin_macros.iter().filter_map(|(name, binding)| {
+ let global_macros = self.global_macros.clone();
+ let names = global_macros.iter().filter_map(|(name, binding)| {
if binding.get_macro(self).kind() == kind {
Some(name)
} else {
module: Module<'a>,
ident: Ident,
ns: Namespace,
- ignore_unresolved_invocations: bool,
+ restricted_shadowing: bool,
record_used: Option<Span>)
-> Result<&'a NameBinding<'a>, Determinacy> {
self.populate_module_if_necessary(module);
if let Some(binding) = resolution.binding {
if let Some(shadowed_glob) = resolution.shadows_glob {
let name = ident.name;
- // If we ignore unresolved invocations, we must forbid
- // expanded shadowing to avoid time travel.
- if ignore_unresolved_invocations &&
+ // Forbid expanded shadowing to avoid time travel.
+ if restricted_shadowing &&
binding.expansion != Mark::root() &&
ns != MacroNS && // In MacroNS, `try_define` always forbids this shadowing
binding.def() != shadowed_glob.def() {
}
let no_unresolved_invocations =
- ignore_unresolved_invocations || module.unresolved_invocations.borrow().is_empty();
+ restricted_shadowing || module.unresolved_invocations.borrow().is_empty();
match resolution.binding {
// In `MacroNS`, expanded bindings do not shadow (enforced in `try_define`).
Some(binding) if no_unresolved_invocations || ns == MacroNS =>
}
// Check if the globs are determined
+ if restricted_shadowing && module.def().is_some() {
+ return Err(Determined);
+ }
for directive in module.globs.borrow().iter() {
if self.is_accessible(directive.vis.get()) {
if let Some(module) = directive.imported_module.get() {
crate-type = ["dylib"]
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
[dependencies]
flate = { path = "../libflate" }
-log = { path = "../liblog" }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_bitflags = { path = "../librustc_bitflags" }
test = false
[dependencies]
-log = { path = "../liblog" }
+log = "0.3"
syntax = { path = "../libsyntax" }
arena = { path = "../libarena" }
fmt_macros = { path = "../libfmt_macros" }
[dependencies]
arena = { path = "../libarena" }
+env_logger = { version = "0.4", default-features = false }
+log = "0.3"
rustc = { path = "../librustc" }
rustc_back = { path = "../librustc_back" }
rustc_const_eval = { path = "../librustc_const_eval" }
-rustc_driver = { path = "../librustc_driver" }
rustc_data_structures = { path = "../librustc_data_structures" }
+rustc_driver = { path = "../librustc_driver" }
rustc_errors = { path = "../librustc_errors" }
rustc_lint = { path = "../librustc_lint" }
rustc_metadata = { path = "../librustc_metadata" }
serialize = { path = "../libserialize" }
syntax = { path = "../libsyntax" }
syntax_pos = { path = "../libsyntax_pos" }
-log = { path = "../liblog" }
[build-dependencies]
build_helper = { path = "../build_helper" }
extern crate arena;
extern crate getopts;
+extern crate env_logger;
extern crate libc;
extern crate rustc;
extern crate rustc_const_eval;
pub fn main() {
const STACK_SIZE: usize = 32_000_000; // 32MB
+ env_logger::init().unwrap();
let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
let s = env::args().collect::<Vec<_>>();
main_args(&s)
[dependencies]
serialize = { path = "../libserialize" }
-log = { path = "../liblog" }
+log = "0.3"
rustc_bitflags = { path = "../librustc_bitflags" }
syntax_pos = { path = "../libsyntax_pos" }
rustc_errors = { path = "../librustc_errors" }
[dependencies]
fmt_macros = { path = "../libfmt_macros" }
-log = { path = "../liblog" }
+log = "0.3"
proc_macro = { path = "../libproc_macro" }
rustc_errors = { path = "../librustc_errors" }
syntax = { path = "../libsyntax" }
--- /dev/null
+// Copyright 2017 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:two_macros.rs
+
+#![feature(use_extern_macros)]
+
+mod foo {
+ extern crate two_macros;
+ pub use self::two_macros::m as panic;
+}
+
+mod m1 {
+ use foo::panic; // ok
+ fn f() { panic!(); }
+}
+
+mod m2 {
+ use foo::*; //~ NOTE `panic` could refer to the name imported here
+ fn f() { panic!(); } //~ ERROR ambiguous
+ //~| NOTE `panic` is also a builtin macro
+ //~| NOTE consider adding an explicit import of `panic` to disambiguate
+}
+
+mod m3 {
+ ::two_macros::m!(use foo::panic;); //~ NOTE `panic` could refer to the name imported here
+ //~| NOTE in this expansion
+ fn f() { panic!(); } //~ ERROR ambiguous
+ //~| NOTE `panic` is also a builtin macro
+ //~| NOTE macro-expanded macro imports do not shadow
+}
+
+mod m4 {
+ macro_rules! panic { () => {} } // ok
+ panic!();
+}
+
+mod m5 {
+ macro_rules! m { () => {
+ macro_rules! panic { () => {} } //~ ERROR `panic` is already in scope
+ //~| NOTE macro-expanded `macro_rules!`s may not shadow existing macros
+ } }
+ m!(); //~ NOTE in this expansion
+ //~| NOTE in this expansion
+ panic!();
+}
+
+#[macro_use(n)] //~ NOTE `n` could also refer to the name imported here
+extern crate two_macros;
+mod bar {
+ pub use two_macros::m as n;
+}
+
+mod m6 {
+ use bar::n; // ok
+ n!();
+}
+
+mod m7 {
+ use bar::*; //~ NOTE `n` could refer to the name imported here
+ n!(); //~ ERROR ambiguous
+ //~| NOTE consider adding an explicit import of `n` to disambiguate
+}
+
+fn main() {}
+++ /dev/null
-// 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() })());
-}
+++ /dev/null
-// 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!() } });
-}
+++ /dev/null
-// 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?");
- }
-}
+++ /dev/null
-// 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?");
- }
-}
+++ /dev/null
-// 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>();
-}
+++ /dev/null
-// 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"));
-}
+++ /dev/null
-// 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();
-}
// 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.
[dependencies]
log = "0.3"
-env_logger = { version = "0.3.5", default-features = false }
+env_logger = { version = "0.4", default-features = false }
rustc-serialize = "0.3"
filetime = "0.1"