Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #92878

Closed
wants to merge 133 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
1788cfd
Remove NullOp::Box
nbdd0121 Sep 26, 2021
d5cbae9
fix clippy
lcnr Dec 23, 2021
dfd3254
Update pulldown-cmark version in clippy
GuillaumeGomez Dec 28, 2021
828ddbe
fix [`redundant_closure`] fp with `Arc`
ebobrow Dec 29, 2021
97ab44c
Merge commit '0eff589afc83e21a03a168497bbab6b4dfbb4ef6' into clippyup
flip1995 Dec 30, 2021
2b5257e
Remove method_call! macro
camsteffen Dec 30, 2021
1f3d6a6
Auto merge of #92252 - GuillaumeGomez:update-pulldown, r=camelid,xFre…
bors Dec 31, 2021
65d1f83
Extend [`unused_io_amount`] to cover AsyncRead and AsyncWrite.
nmathewson Dec 27, 2021
b6bcf0c
unused_io_amount: Use span_lint_and_help.
nmathewson Dec 31, 2021
490566b
Auto merge of #8179 - nmathewson:unused_async_io_amount, r=xFrednet
bors Dec 31, 2021
c736a63
Auto merge of #8193 - ebobrow:redundant_closure_fp, r=Manishearth
bors Dec 31, 2021
3d41358
wrong_self_convention: Match `SelfKind::No` more restrictively
nmathewson Jan 1, 2022
f5bbd1b
Make tidy check for magic numbers that spell things
joshtriplett Jan 1, 2022
262b148
return_self_not_must_use document `#[must_use]` on the type
bors Jan 1, 2022
7616eb0
Auto merge of #8209 - xFrednet:8197-mention-attribute-on-struct, r=ll…
bors Jan 1, 2022
b25dbc6
Auto merge of #8208 - nmathewson:selfkind_no_fix, r=xFrednet
bors Jan 2, 2022
e8b6b2a
erasing_op lint ignored when output type is different from the non-co…
Dec 31, 2021
8419108
Auto merge of #8204 - wigy-opensource-developer:fix-7210, r=xFrednet
bors Jan 2, 2022
6975071
Rollup merge of #90102 - nbdd0121:box3, r=jonas-schievink
matthiaskrgr Jan 3, 2022
19cfcd5
Fix clippy warnings
pmnoxx Jan 3, 2022
3ea7784
Auto merge of #8216 - pmnoxx:piotr-fix-clippy-warnings, r=xFrednet
bors Jan 3, 2022
ff58efb
Better detect when a field can be moved from in `while_let_on_iterator`
Jarcho Jan 4, 2022
00da1b8
Remove in_macro from utils
camsteffen Jan 4, 2022
a7097b8
Consider auto-deref when linting `manual_swap`
Jarcho Jan 4, 2022
0e28e38
Auto merge of #8220 - Jarcho:manual_swap_8154, r=camsteffen
bors Jan 4, 2022
2dd216a
Check for full equality in `type_repetition_in_bounds` rather than ju…
Jarcho Jan 4, 2022
d7a6033
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
matthiaskrgr Jan 4, 2022
786f874
New macro utils
bors Jan 4, 2022
ba03dc7
Auto merge of #8219 - camsteffen:macro-decoupling, r=llogiq
bors Jan 4, 2022
d5dcda2
Auto merge of #8223 - camsteffen:remove-in-macro, r=llogiq
bors Jan 5, 2022
20f2a89
Auto merge of #8224 - Jarcho:type_repetition_in_bounds_8162, r=llogiq
bors Jan 5, 2022
92048f4
Auto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq
bors Jan 5, 2022
a4ebf6f
Change `unnecessary_to_owned` `into_iter` suggestions to `MaybeIncorr…
smoelius Dec 30, 2021
14f3445
Don't lint `DequeVec` in `manual_memcpy`
Jarcho Jan 5, 2022
3925def
Suggest `copy_from_slice` for `manual_memcpy` when possible
Jarcho Jan 5, 2022
2cc38a2
Lint `iter_not_returning_iterator` on the trait definition rather tha…
Jarcho Jan 5, 2022
d98339d
Handle type projections in `iter_not_returning_iterator`
Jarcho Jan 5, 2022
94fe671
Allow running lintcheck with a renamed rust-clippy dir
Alexendoo Jan 6, 2022
be7cf76
Auto merge of #8234 - Alexendoo:lintcheck-allow-renamed-dir, r=xFrednet
bors Jan 7, 2022
c34e3f0
Update clippy for associated item changes
matthewjasper Nov 18, 2021
6a1f9e6
mangling_v0: Update tests for the rust-demangler tool
petrochenkov Dec 26, 2021
1b8daf8
mangling_v0: Add a test for mangling of foreign types
petrochenkov Dec 27, 2021
333a5cc
mangling_v0: Skip extern blocks during mangling
petrochenkov Dec 27, 2021
366234a
Add `unnecessary_to_owned` "Known problems" section
smoelius Jan 8, 2022
917890b
Auto merge of #8201 - smoelius:master, r=camsteffen
bors Jan 8, 2022
3ea5208
Set binary-dep-depinfo in .cargo/config.toml
sourcefrog Jan 8, 2022
83a9f68
Auto merge of #8249 - sourcefrog:depinfo, r=Manishearth
bors Jan 9, 2022
1288b80
rustc_metadata: Optimize and document module children decoding
petrochenkov Dec 18, 2021
c8ea042
rustc_metadata: Rename `item_children(_untracked)` to `module_childre…
petrochenkov Dec 23, 2021
f690978
cover trait for `trait_duplication_in_bounds`
dswij Jan 6, 2022
a6f80fc
new lint: `single_char_lifetime_names`
bors Jan 9, 2022
5991695
Auto merge of #8236 - PatchMixolydic:single_char_lifetime_names, r=ll…
bors Jan 9, 2022
16d8488
Combine internal features in clippy_utils
camsteffen Jan 10, 2022
e2ce4f9
Combine internal features in clippy_lints
camsteffen Jan 10, 2022
f4dc348
`trait_duplication_in_bounds` Update description and add test
dswij Jan 10, 2022
88cfd70
Auto merge of #8252 - dswij:8229, r=xFrednet
bors Jan 10, 2022
1816361
Auto merge of #8257 - camsteffen:internal-features, r=giraffate
bors Jan 10, 2022
b66dbe8
Auto merge of #8228 - Jarcho:iter_not_returning_iterator_8225, r=gira…
bors Jan 10, 2022
cf86cee
Downgrade mutex_atomic to nursery
taiki-e Jan 10, 2022
5f143c6
Warn disallowed_methods and disallowed_types by default
taiki-e Jan 10, 2022
e66ecf6
Run dogfood on windows
camsteffen Jan 10, 2022
7cf4f44
Fix output capturing
camsteffen Jan 10, 2022
51dbbf3
Refactor test utils
camsteffen Jan 10, 2022
d356fb9
Use `rustup which rustfmt`
camsteffen Jan 10, 2022
920e9f0
Move workspace test
camsteffen Jan 10, 2022
4a54933
Merge dogfood tests
camsteffen Jan 10, 2022
21343ab
Remove rustfmt component check
camsteffen Jan 10, 2022
51282fc
Auto merge of #8261 - taiki-e:disallowed, r=giraffate
bors Jan 10, 2022
01ef7c7
Fix dogfood
camsteffen Jan 10, 2022
fccf07b
Auto merge of #8260 - taiki-e:mutex_atomic, r=llogiq
bors Jan 11, 2022
3298de7
Add borrow_as_ptr lint
guerinoni Jan 2, 2022
fd97d79
`README`: `clippy-driver` is not a replacement for `rustc`
ojeda Nov 27, 2021
3d4fded
`README`: mention `clippy-driver` on usage list
ojeda Dec 14, 2021
dda2aef
Store a `Symbol` instead of an `Ident` in `VariantDef`/`FieldDef`
Aaron1011 Jan 3, 2022
fd9cebe
Auto merge of #8210 - guerinoni:master, r=Manishearth
bors Jan 11, 2022
02ec39b
Stop using in_band_lifetimes
camsteffen Jan 11, 2022
8680a44
Partially stabilize `maybe_uninit_extra`
ojeda Jan 11, 2022
7e989ec
Improve documentation for `borrowed-box` lint
1nF0rmed Jan 10, 2022
88f5be2
Auto merge of #8262 - 1nF0rmed:chore-update-borrowed-box-doc, r=camst…
bors Jan 11, 2022
4839b81
fs: Use readdir() instead of readdir_r() on Linux
tavianator Jan 11, 2022
40f33a7
Deduplicate box deref and regular deref suggestions
compiler-errors Jan 12, 2022
d32277d
Don't lint `deref_addrof` when the two operations occur in different …
Jarcho Jan 12, 2022
1dc9c59
Override rustc version in ui and mir-opt tests to get stable hashes
the8472 Dec 28, 2021
9c6ae12
use lazy_static to compile `Regex::new` instances once instead on eac…
the8472 Jan 5, 2022
37e9985
Auto merge of #8268 - Jarcho:deref_addrof_8247, r=flip1995
bors Jan 12, 2022
0d94167
Auto merge of #8198 - camsteffen:no-method-call-macro, r=flip1995
bors Jan 12, 2022
956db07
Don't fall back to crate-level opaque type definitions.
oli-obk Dec 8, 2021
ae01c4a
Auto merge of #8190 - camsteffen:no-in-band-liftetimes, r=flip1995
bors Jan 12, 2022
b9cae79
Auto merge of #8037 - ojeda:doc-codegen-change, r=camsteffen
bors Jan 12, 2022
166737f
Add manual_bits lint
paolobarbolini Jan 2, 2022
91581f6
Resolve primitive impls in clippy_utils::path_to_res
Alexendoo Dec 9, 2021
7c82ae1
Auto merge of #8213 - paolobarbolini:size-of-as-bits, r=flip1995
bors Jan 12, 2022
04eb27a
Use method name from conf::DisallowedMethod
Alexendoo Dec 9, 2021
6f33f69
Auto merge of #8112 - Alexendoo:disallowed_methods_primitives, r=flip…
bors Jan 12, 2022
90bf72c
Only run dogfood on linux in CI
camsteffen Jan 12, 2022
133b366
Auto merge of #8265 - camsteffen:which-rustfmt, r=xFrednet
bors Jan 12, 2022
5479024
Auto merge of #8266 - camsteffen:test-tweaks, r=flip1995
bors Jan 12, 2022
062db10
Add `manual_memcpy_test` for `VecDeque`
Jarcho Jan 12, 2022
0cf7fd1
Call out to binutils' dlltool for raw-dylib on windows-gnu platforms.
ricobbe Nov 1, 2021
60e68d6
Auto merge of #8226 - Jarcho:manual_memcpy_8160, r=flip1995
bors Jan 12, 2022
8568f44
suggest deref/unboxing before wrapping variant
compiler-errors Jan 12, 2022
3501a0c
Remove unused link references.
ehuss Jan 13, 2022
d536886
Remove duplicate cargo/4270. It was part of 1.21.
ehuss Jan 13, 2022
73cb56e
Remove duplicate #39983. It was part of 1.19.
ehuss Jan 13, 2022
dadf78c
Fix incorrect link for #38622.
ehuss Jan 13, 2022
1e1660d
Fix link name collision for cargo#2365 (1.8cv)
ehuss Jan 13, 2022
8f840d9
Fix some links that had colliding reference names.
ehuss Jan 13, 2022
7b74ded
Fix lints documents
hafeoz Jan 13, 2022
11be495
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Jan 13, 2022
8a2141b
Bump Clippy Version -> 0.1.60
flip1995 Jan 13, 2022
6ad05bc
Bump nightly version -> 2022-01-13
flip1995 Jan 13, 2022
97a5daa
Auto merge of #8272 - flip1995:rustup, r=flip1995
bors Jan 13, 2022
ba66384
Merge commit '97a5daa65908e59744e2bc625b14849352231c75' into clippyup
flip1995 Jan 13, 2022
159d6c3
Update Cargo.lock
flip1995 Jan 13, 2022
b83c77c
Fix Clippy sync fallout
flip1995 Jan 13, 2022
bc6b199
Use the updated Rust logo and change it's format to SVG
Urgau Jan 13, 2022
b8ef148
Regenerate the PNGs favicon with the updated Rust logo
Urgau Jan 13, 2022
7cc6a73
Remove `asm` feature from lints example
hafeoz Jan 13, 2022
d5871d0
Fix and improve missing dot in the item heading
Jan 13, 2022
241d977
Update documentation for doc_cfg
GuillaumeGomez Jan 12, 2022
c3258b9
Rollup merge of #90782 - ricobbe:binutils-dlltool, r=michaelwoerister
matthiaskrgr Jan 14, 2022
cc84ed2
Rollup merge of #92045 - oli-obk:cleanup, r=petrochenkov
matthiaskrgr Jan 14, 2022
3c2fed6
Rollup merge of #92316 - petrochenkov:extmangle, r=wesleywiser
matthiaskrgr Jan 14, 2022
773860a
Rollup merge of #92363 - the8472:less-compiletest-normalization, r=Ma…
matthiaskrgr Jan 14, 2022
fbe2321
Rollup merge of #92768 - ojeda:stabilize-maybe_uninit_extra, r=Mark-S…
matthiaskrgr Jan 14, 2022
749b557
Rollup merge of #92778 - tavianator:linux-readdir-no-r, r=joshtriplett
matthiaskrgr Jan 14, 2022
1b2f969
Rollup merge of #92810 - compiler-errors:deduplicate-box-deref-sugges…
matthiaskrgr Jan 14, 2022
826b2b2
Rollup merge of #92818 - GuillaumeGomez:update-doc-cfg-doc, r=camelid
matthiaskrgr Jan 14, 2022
87f4baa
Rollup merge of #92838 - ehuss:cleanup-release-links, r=Mark-Simulacrum
matthiaskrgr Jan 14, 2022
2c413c5
Rollup merge of #92840 - hafeoz:master, r=ehuss
matthiaskrgr Jan 14, 2022
99fe99a
Rollup merge of #92849 - flip1995:clippyup, r=Manishearth
matthiaskrgr Jan 14, 2022
ace998e
Rollup merge of #92854 - Urgau:better-rust-logo, r=GuillaumeGomez
matthiaskrgr Jan 14, 2022
5208fe2
Rollup merge of #92864 - Urgau:fix-missing-source-dot, r=jsha
matthiaskrgr Jan 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 6 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,15 @@ dependencies = [

[[package]]
name = "clippy"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"cargo_metadata 0.14.0",
"clippy_lints",
"clippy_utils",
"compiletest_rs",
"derive-new",
"filetime",
"futures 0.3.12",
"if_chain",
"itertools 0.10.1",
"parking_lot",
Expand All @@ -633,6 +634,7 @@ dependencies = [
"syn",
"tempfile",
"tester",
"tokio",
]

[[package]]
Expand All @@ -652,7 +654,7 @@ dependencies = [

[[package]]
name = "clippy_lints"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"cargo_metadata 0.14.0",
"clippy_utils",
Expand All @@ -673,8 +675,9 @@ dependencies = [

[[package]]
name = "clippy_utils"
version = "0.1.59"
version = "0.1.60"
dependencies = [
"arrayvec",
"if_chain",
"rustc-semver",
]
Expand Down
142 changes: 16 additions & 126 deletions RELEASES.md

Large diffs are not rendered by default.

205 changes: 159 additions & 46 deletions compiler/rustc_codegen_llvm/src/back/archive.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! A helper class for dealing with static archives

use std::ffi::{CStr, CString};
use std::env;
use std::ffi::{CStr, CString, OsString};
use std::io;
use std::mem;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -158,54 +159,127 @@ impl<'a> ArchiveBuilder<'a> for LlvmArchiveBuilder<'a> {
output_path.with_extension("lib")
};

// we've checked for \0 characters in the library name already
let dll_name_z = CString::new(lib_name).unwrap();
// All import names are Rust identifiers and therefore cannot contain \0 characters.
// FIXME: when support for #[link_name] implemented, ensure that import.name values don't
// have any \0 characters
let import_name_and_ordinal_vector: Vec<(CString, Option<u16>)> = dll_imports
let mingw_gnu_toolchain = self.config.sess.target.llvm_target.ends_with("pc-windows-gnu");

let import_name_and_ordinal_vector: Vec<(String, Option<u16>)> = dll_imports
.iter()
.map(|import: &DllImport| {
if self.config.sess.target.arch == "x86" {
(LlvmArchiveBuilder::i686_decorated_name(import), import.ordinal)
(
LlvmArchiveBuilder::i686_decorated_name(import, mingw_gnu_toolchain),
import.ordinal,
)
} else {
(CString::new(import.name.to_string()).unwrap(), import.ordinal)
(import.name.to_string(), import.ordinal)
}
})
.collect();

let output_path_z = rustc_fs_util::path_to_c_string(&output_path);
if mingw_gnu_toolchain {
// The binutils linker used on -windows-gnu targets cannot read the import
// libraries generated by LLVM: in our attempts, the linker produced an .EXE
// that loaded but crashed with an AV upon calling one of the imported
// functions. Therefore, use binutils to create the import library instead,
// by writing a .DEF file to the temp dir and calling binutils's dlltool.
let def_file_path =
tmpdir.as_ref().join(format!("{}_imports", lib_name)).with_extension("def");

let def_file_content = format!(
"EXPORTS\n{}",
import_name_and_ordinal_vector
.into_iter()
.map(|(name, ordinal)| {
match ordinal {
Some(n) => format!("{} @{} NONAME", name, n),
None => name,
}
})
.collect::<Vec<String>>()
.join("\n")
);

tracing::trace!("invoking LLVMRustWriteImportLibrary");
tracing::trace!(" dll_name {:#?}", dll_name_z);
tracing::trace!(" output_path {}", output_path.display());
tracing::trace!(
" import names: {}",
dll_imports.iter().map(|import| import.name.to_string()).collect::<Vec<_>>().join(", "),
);
match std::fs::write(&def_file_path, def_file_content) {
Ok(_) => {}
Err(e) => {
self.config.sess.fatal(&format!("Error writing .DEF file: {}", e));
}
};

let ffi_exports: Vec<LLVMRustCOFFShortExport> = import_name_and_ordinal_vector
.iter()
.map(|(name_z, ordinal)| LLVMRustCOFFShortExport::new(name_z.as_ptr(), *ordinal))
.collect();
let result = unsafe {
crate::llvm::LLVMRustWriteImportLibrary(
dll_name_z.as_ptr(),
output_path_z.as_ptr(),
ffi_exports.as_ptr(),
ffi_exports.len(),
llvm_machine_type(&self.config.sess.target.arch) as u16,
!self.config.sess.target.is_like_msvc,
)
};
let dlltool = find_binutils_dlltool(self.config.sess);
let result = std::process::Command::new(dlltool)
.args([
"-d",
def_file_path.to_str().unwrap(),
"-D",
lib_name,
"-l",
output_path.to_str().unwrap(),
])
.output();

match result {
Err(e) => {
self.config.sess.fatal(&format!("Error calling dlltool: {}", e.to_string()));
}
Ok(output) if !output.status.success() => self.config.sess.fatal(&format!(
"Dlltool could not create import library: {}\n{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
)),
_ => {}
}
} else {
// we've checked for \0 characters in the library name already
let dll_name_z = CString::new(lib_name).unwrap();

let output_path_z = rustc_fs_util::path_to_c_string(&output_path);

tracing::trace!("invoking LLVMRustWriteImportLibrary");
tracing::trace!(" dll_name {:#?}", dll_name_z);
tracing::trace!(" output_path {}", output_path.display());
tracing::trace!(
" import names: {}",
dll_imports
.iter()
.map(|import| import.name.to_string())
.collect::<Vec<_>>()
.join(", "),
);

if result == crate::llvm::LLVMRustResult::Failure {
self.config.sess.fatal(&format!(
"Error creating import library for {}: {}",
lib_name,
llvm::last_error().unwrap_or("unknown LLVM error".to_string())
));
}
// All import names are Rust identifiers and therefore cannot contain \0 characters.
// FIXME: when support for #[link_name] is implemented, ensure that the import names
// still don't contain any \0 characters. Also need to check that the names don't
// contain substrings like " @" or "NONAME" that are keywords or otherwise reserved
// in definition files.
let cstring_import_name_and_ordinal_vector: Vec<(CString, Option<u16>)> =
import_name_and_ordinal_vector
.into_iter()
.map(|(name, ordinal)| (CString::new(name).unwrap(), ordinal))
.collect();

let ffi_exports: Vec<LLVMRustCOFFShortExport> = cstring_import_name_and_ordinal_vector
.iter()
.map(|(name_z, ordinal)| LLVMRustCOFFShortExport::new(name_z.as_ptr(), *ordinal))
.collect();
let result = unsafe {
crate::llvm::LLVMRustWriteImportLibrary(
dll_name_z.as_ptr(),
output_path_z.as_ptr(),
ffi_exports.as_ptr(),
ffi_exports.len(),
llvm_machine_type(&self.config.sess.target.arch) as u16,
!self.config.sess.target.is_like_msvc,
)
};

if result == crate::llvm::LLVMRustResult::Failure {
self.config.sess.fatal(&format!(
"Error creating import library for {}: {}",
lib_name,
llvm::last_error().unwrap_or("unknown LLVM error".to_string())
));
}
};

self.add_archive(&output_path, |_| false).unwrap_or_else(|e| {
self.config.sess.fatal(&format!(
Expand Down Expand Up @@ -332,22 +406,61 @@ impl<'a> LlvmArchiveBuilder<'a> {
}
}

fn i686_decorated_name(import: &DllImport) -> CString {
fn i686_decorated_name(import: &DllImport, mingw: bool) -> String {
let name = import.name;
// We verified during construction that `name` does not contain any NULL characters, so the
// conversion to CString is guaranteed to succeed.
CString::new(match import.calling_convention {
DllCallingConvention::C => format!("_{}", name),
DllCallingConvention::Stdcall(arg_list_size) => format!("_{}@{}", name, arg_list_size),
let prefix = if mingw { "" } else { "_" };

match import.calling_convention {
DllCallingConvention::C => format!("{}{}", prefix, name),
DllCallingConvention::Stdcall(arg_list_size) => {
format!("{}{}@{}", prefix, name, arg_list_size)
}
DllCallingConvention::Fastcall(arg_list_size) => format!("@{}@{}", name, arg_list_size),
DllCallingConvention::Vectorcall(arg_list_size) => {
format!("{}@@{}", name, arg_list_size)
}
})
.unwrap()
}
}
}

fn string_to_io_error(s: String) -> io::Error {
io::Error::new(io::ErrorKind::Other, format!("bad archive: {}", s))
}

fn find_binutils_dlltool(sess: &Session) -> OsString {
assert!(sess.target.options.is_like_windows && !sess.target.options.is_like_msvc);
if let Some(dlltool_path) = &sess.opts.debugging_opts.dlltool {
return dlltool_path.clone().into_os_string();
}

let mut tool_name: OsString = if sess.host.arch != sess.target.arch {
// We are cross-compiling, so we need the tool with the prefix matching our target
if sess.target.arch == "x86" {
"i686-w64-mingw32-dlltool"
} else {
"x86_64-w64-mingw32-dlltool"
}
} else {
// We are not cross-compiling, so we just want `dlltool`
"dlltool"
}
.into();

if sess.host.options.is_like_windows {
// If we're compiling on Windows, add the .exe suffix
tool_name.push(".exe");
}

// NOTE: it's not clear how useful it is to explicitly search PATH.
for dir in env::split_paths(&env::var_os("PATH").unwrap_or_default()) {
let full_path = dir.join(&tool_name);
if full_path.is_file() {
return full_path.into_os_string();
}
}

// The user didn't specify the location of the dlltool binary, and we weren't able
// to find the appropriate one on the PATH. Just return the name of the tool
// and let the invocation fail with a hopefully useful error message.
tool_name
}
18 changes: 9 additions & 9 deletions compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub(crate) use self::undo_log::{InferCtxtUndoLogs, Snapshot, UndoLog};

use crate::traits::{self, ObligationCause, PredicateObligations, TraitEngine};

use hir::def_id::CRATE_DEF_ID;
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
use rustc_data_structures::sync::Lrc;
use rustc_data_structures::undo_log::Rollback;
Expand Down Expand Up @@ -291,7 +290,12 @@ pub struct InferCtxt<'a, 'tcx> {

/// The `DefId` of the item in whose context we are performing inference or typeck.
/// It is used to check whether an opaque type use is a defining use.
pub defining_use_anchor: LocalDefId,
///
/// If it is `None`, we can't resolve opaque types here and need to bubble up
/// the obligation. This frequently happens for
/// short lived InferCtxt within queries. The opaque type obligations are forwarded
/// to the outside until the end up in an `InferCtxt` for typeck or borrowck.
pub defining_use_anchor: Option<LocalDefId>,

/// During type-checking/inference of a body, `in_progress_typeck_results`
/// contains a reference to the typeck results being built up, which are
Expand Down Expand Up @@ -547,7 +551,7 @@ impl<'tcx> fmt::Display for FixupError<'tcx> {
pub struct InferCtxtBuilder<'tcx> {
tcx: TyCtxt<'tcx>,
fresh_typeck_results: Option<RefCell<ty::TypeckResults<'tcx>>>,
defining_use_anchor: LocalDefId,
defining_use_anchor: Option<LocalDefId>,
}

pub trait TyCtxtInferExt<'tcx> {
Expand All @@ -556,11 +560,7 @@ pub trait TyCtxtInferExt<'tcx> {

impl<'tcx> TyCtxtInferExt<'tcx> for TyCtxt<'tcx> {
fn infer_ctxt(self) -> InferCtxtBuilder<'tcx> {
InferCtxtBuilder {
tcx: self,
defining_use_anchor: CRATE_DEF_ID,
fresh_typeck_results: None,
}
InferCtxtBuilder { tcx: self, defining_use_anchor: None, fresh_typeck_results: None }
}
}

Expand All @@ -580,7 +580,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
/// (via `with_fresh_in_progress_typeck_results`) and for the inference context used
/// in mir borrowck.
pub fn with_opaque_type_inference(mut self, defining_use_anchor: LocalDefId) -> Self {
self.defining_use_anchor = defining_use_anchor;
self.defining_use_anchor = Some(defining_use_anchor);
self
}

Expand Down
Loading