Skip to content

Rollup of 8 pull requests #42032

New issue

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

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

Already on GitHub? Sign in to your account

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
df188b8
Add lint for unused macros
est31 May 11, 2017
db82c57
Extend the libsyntax visitor to work over macro defs
est31 May 12, 2017
d14d194
Support #[allow] etc logic on a per macro level
est31 May 12, 2017
ba0601d
libcore: #[allow] some unused macros
est31 May 12, 2017
b36d23c
Add test, and fix the other tests
est31 May 12, 2017
0d0cb27
librustc_incremental: remove unused macro in test case
est31 May 14, 2017
a9cb094
Explain why `thread::yield_now` could be used.
May 13, 2017
a51777e
Improve `thread::Builder` documentation.
May 14, 2017
93f78bc
rustdoc: Display `extern "C" fn` instead of `extern fn`
ollie27 May 14, 2017
173f693
Rewrite make-win-dist.py in Rust
wesleywiser May 6, 2017
c0d5aa8
Make unsatisfied trait bounds note multiline
estebank Apr 24, 2017
25b7f10
Address review comments
est31 May 15, 2017
f92bd3d
Add links to the `thread::LocalKey` doc.
May 14, 2017
9f4e1e1
Fix regression in `macro_rules!` name matching.
jseyfried May 15, 2017
6dbd706
put option_try macro def under #[cfg(unix)]
est31 May 16, 2017
a49d6c1
Rollup merge of #41489 - estebank:trait-bounds-diagnosstic, r=arielb1
Mark-Simulacrum May 16, 2017
38bdfdc
Rollup merge of #41907 - est31:macro_unused, r=jseyfried
Mark-Simulacrum May 16, 2017
0dc1d45
Rollup merge of #41932 - wesleywiser:py-to-rust, r=alexcrichton
Mark-Simulacrum May 16, 2017
e4a4f53
Rollup merge of #41982 - gamazeps:thread-yield-now, r=GuillaumeGomez
Mark-Simulacrum May 16, 2017
b5a24d4
Rollup merge of #41994 - gamazeps:thread-builder, r=GuillaumeGomez
Mark-Simulacrum May 16, 2017
4e48bfb
Rollup merge of #41995 - gamazeps:thread-localkey, r=frewsxcv
Mark-Simulacrum May 16, 2017
bf3abe0
Rollup merge of #42001 - ollie27:rustdoc_extern_fn, r=GuillaumeGomez
Mark-Simulacrum May 16, 2017
747f7d2
Rollup merge of #42005 - jseyfried:fix_macro_regression, r=nrc
Mark-Simulacrum May 16, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 136 additions & 17 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,139 @@ pub fn docs(build: &Build, stage: u32, host: &str) {
}
}

fn find_files(files: &[&str], path: &[PathBuf]) -> Vec<PathBuf> {
let mut found = Vec::new();

for file in files {
let file_path =
path.iter()
.map(|dir| dir.join(file))
.find(|p| p.exists());

if let Some(file_path) = file_path {
found.push(file_path);
} else {
panic!("Could not find '{}' in {:?}", file, path);
}
}

found
}

fn make_win_dist(rust_root: &Path, plat_root: &Path, target_triple: &str, build: &Build) {
//Ask gcc where it keeps its stuff
let mut cmd = Command::new(build.cc(target_triple));
cmd.arg("-print-search-dirs");
build.run_quiet(&mut cmd);
let gcc_out =
String::from_utf8(
cmd
.output()
.expect("failed to execute gcc")
.stdout).expect("gcc.exe output was not utf8");

let mut bin_path: Vec<_> =
env::split_paths(&env::var_os("PATH").unwrap_or_default())
.collect();
let mut lib_path = Vec::new();

for line in gcc_out.lines() {
let idx = line.find(':').unwrap();
let key = &line[..idx];
let trim_chars: &[_] = &[' ', '='];
let value =
line[(idx + 1)..]
.trim_left_matches(trim_chars)
.split(';')
.map(|s| PathBuf::from(s));

if key == "programs" {
bin_path.extend(value);
} else if key == "libraries" {
lib_path.extend(value);
}
}

let target_tools = vec!["gcc.exe", "ld.exe", "ar.exe", "dlltool.exe", "libwinpthread-1.dll"];
let mut rustc_dlls = vec!["libstdc++-6.dll", "libwinpthread-1.dll"];
if target_triple.starts_with("i686-") {
rustc_dlls.push("libgcc_s_dw2-1.dll");
} else {
rustc_dlls.push("libgcc_s_seh-1.dll");
}

let target_libs = vec![ //MinGW libs
"libgcc.a",
"libgcc_eh.a",
"libgcc_s.a",
"libm.a",
"libmingw32.a",
"libmingwex.a",
"libstdc++.a",
"libiconv.a",
"libmoldname.a",
"libpthread.a",
//Windows import libs
"libadvapi32.a",
"libbcrypt.a",
"libcomctl32.a",
"libcomdlg32.a",
"libcrypt32.a",
"libgdi32.a",
"libimagehlp.a",
"libiphlpapi.a",
"libkernel32.a",
"libmsvcrt.a",
"libodbc32.a",
"libole32.a",
"liboleaut32.a",
"libopengl32.a",
"libpsapi.a",
"librpcrt4.a",
"libsetupapi.a",
"libshell32.a",
"libuser32.a",
"libuserenv.a",
"libuuid.a",
"libwinhttp.a",
"libwinmm.a",
"libwinspool.a",
"libws2_32.a",
"libwsock32.a",
];

//Find mingw artifacts we want to bundle
let target_tools = find_files(&target_tools, &bin_path);
let rustc_dlls = find_files(&rustc_dlls, &bin_path);
let target_libs = find_files(&target_libs, &lib_path);

fn copy_to_folder(src: &Path, dest_folder: &Path) {
let file_name = src.file_name().unwrap().to_os_string();
let dest = dest_folder.join(file_name);
copy(src, &dest);
}

//Copy runtime dlls next to rustc.exe
let dist_bin_dir = rust_root.join("bin/");
for src in rustc_dlls {
copy_to_folder(&src, &dist_bin_dir);
}

//Copy platform tools to platform-specific bin directory
let target_bin_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("bin");
fs::create_dir_all(&target_bin_dir).expect("creating target_bin_dir failed");
for src in target_tools {
copy_to_folder(&src, &target_bin_dir);
}

//Copy platform libs to platform-specific lib directory
let target_lib_dir = plat_root.join("lib").join("rustlib").join(target_triple).join("lib");
fs::create_dir_all(&target_lib_dir).expect("creating target_lib_dir failed");
for src in target_libs {
copy_to_folder(&src, &target_lib_dir);
}
}

/// Build the `rust-mingw` installer component.
///
/// This contains all the bits and pieces to run the MinGW Windows targets
Expand All @@ -109,18 +242,11 @@ pub fn mingw(build: &Build, host: &str) {
let _ = fs::remove_dir_all(&image);
t!(fs::create_dir_all(&image));

// The first argument to the script is a "temporary directory" which is just
// The first argument is a "temporary directory" which is just
// thrown away (this contains the runtime DLLs included in the rustc package
// above) and the second argument is where to place all the MinGW components
// (which is what we want).
//
// FIXME: this script should be rewritten into Rust
let mut cmd = Command::new(build.python());
cmd.arg(build.src.join("src/etc/make-win-dist.py"))
.arg(tmpdir(build))
.arg(&image)
.arg(host);
build.run(&mut cmd);
make_win_dist(&tmpdir(build), &image, host, &build);

let mut cmd = rust_installer(build);
cmd.arg("generate")
Expand Down Expand Up @@ -172,15 +298,8 @@ pub fn rustc(build: &Build, stage: u32, host: &str) {
// anything requiring us to distribute a license, but it's likely the
// install will *also* include the rust-mingw package, which also needs
// licenses, so to be safe we just include it here in all MinGW packages.
//
// FIXME: this script should be rewritten into Rust
if host.contains("pc-windows-gnu") {
let mut cmd = Command::new(build.python());
cmd.arg(build.src.join("src/etc/make-win-dist.py"))
.arg(&image)
.arg(tmpdir(build))
.arg(host);
build.run(&mut cmd);
make_win_dist(&image, &tmpdir(build), host, build);

let dst = image.join("share/doc");
t!(fs::create_dir_all(&dst));
Expand Down
126 changes: 0 additions & 126 deletions src/etc/make-win-dist.py

This file was deleted.

1 change: 1 addition & 0 deletions src/libcore/num/wrapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use super::Wrapping;

use ops::*;

#[allow(unused_macros)]
macro_rules! sh_impl_signed {
($t:ident, $f:ident) => (
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
1 change: 1 addition & 0 deletions src/libcore/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ macro_rules! neg_impl_numeric {
($($t:ty)*) => { neg_impl_core!{ x => -x, $($t)*} }
}

#[allow(unused_macros)]
macro_rules! neg_impl_unsigned {
($($t:ty)*) => {
neg_impl_core!{ x => {
Expand Down
7 changes: 7 additions & 0 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ declare_lint! {
"detects unreachable patterns"
}

declare_lint! {
pub UNUSED_MACROS,
Warn,
"detects macros that were not used"
}

declare_lint! {
pub WARNINGS,
Warn,
Expand Down Expand Up @@ -259,6 +265,7 @@ impl LintPass for HardwiredLints {
DEAD_CODE,
UNREACHABLE_CODE,
UNREACHABLE_PATTERNS,
UNUSED_MACROS,
WARNINGS,
UNUSED_FEATURES,
STABLE_FEATURES,
Expand Down
8 changes: 8 additions & 0 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use hir;
use hir::def_id::LOCAL_CRATE;
use hir::intravisit as hir_visit;
use syntax::visit as ast_visit;
use syntax::tokenstream::ThinTokenStream;

/// Information about the registered lints.
///
Expand Down Expand Up @@ -1125,6 +1126,13 @@ impl<'a> ast_visit::Visitor<'a> for EarlyContext<'a> {
fn visit_attribute(&mut self, attr: &'a ast::Attribute) {
run_lints!(self, check_attribute, early_passes, attr);
}

fn visit_mac_def(&mut self, _mac: &'a ThinTokenStream, id: ast::NodeId) {
let lints = self.sess.lints.borrow_mut().take(id);
for early_lint in lints {
self.early_lint(&early_lint);
}
}
}

enum CheckLintNameResult {
Expand Down
1 change: 1 addition & 0 deletions src/librustc/util/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub fn record_time<T, F>(accu: &Cell<Duration>, f: F) -> T where
}

// Like std::macros::try!, but for Option<>.
#[cfg(unix)]
macro_rules! option_try(
($e:expr) => (match $e { Some(e) => e, None => return None })
);
Expand Down
2 changes: 2 additions & 0 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,

let krate = ecx.monotonic_expander().expand_crate(krate);

ecx.check_unused_macros();

let mut missing_fragment_specifiers: Vec<_> =
ecx.parse_sess.missing_fragment_specifiers.borrow().iter().cloned().collect();
missing_fragment_specifiers.sort();
Expand Down
11 changes: 0 additions & 11 deletions src/librustc_incremental/persist/preds/compress/test_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,3 @@ macro_rules! graph {
}
}
}

macro_rules! set {
($( $value:expr ),*) => {
{
use $crate::rustc_data_structures::fx::FxHashSet;
let mut set = FxHashSet();
$(set.insert($value);)*
set
}
}
}
Loading