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 12 pull requests #73864

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
5c20ef4
bootstrap: Configurable musl libdir
tmiasko Jun 17, 2020
0c88dd6
Update Box::from_raw example to generalize better
Keno Jun 24, 2020
2bbc2b3
Document the static keyword
poliorcetics Jun 25, 2020
00ef461
Merge pull request #2 from rust-lang/master
TyPR124 Jun 26, 2020
b71a3e1
Map ERROR_INVALID_PARAMETER to InvalidInput
TyPR124 Jun 26, 2020
0d0865f
Make `rustc_peek` a safe intrinsic
oli-obk Jun 27, 2020
3fc5593
Document the type keyword
poliorcetics Jun 27, 2020
517d361
Use an 'approximate' universal upper bound when reporting region errors
Aaron1011 Jun 27, 2020
7055c23
ast_pretty: Pass some token streams and trees by reference
petrochenkov Jun 24, 2020
14d0370
Remove defunct `-Z print-region-graph`
tmiasko Jun 28, 2020
7231e57
Fix wording for anonymous parameter name help
nop Jun 28, 2020
e611a3f
Apply suggestions from code review
poliorcetics Jun 28, 2020
e8f5785
Split and expand nonstandard-style lints unicode unit test.
crlf0710 Jun 28, 2020
dfd454b
Apply suggestions, reformulating some paragraphs and improving some e…
poliorcetics Jun 28, 2020
824b2bb
Match on `Symbol` instead of `&str` for type-checking intrinsics.
oli-obk Jun 28, 2020
4224313
Fix small nits
poliorcetics Jun 28, 2020
3dfbf0b
rustbuild: Move compiler-builtins build logic to manifest
alexcrichton Jun 15, 2020
a447cfe
Rollup merge of #73374 - alexcrichton:compiler-bulitins-debug-asserti…
Manishearth Jun 29, 2020
db95513
Rollup merge of #73456 - tmiasko:musl-libdir, r=Mark-Simulacrum
Manishearth Jun 29, 2020
baf7f99
Rollup merge of #73678 - Keno:patch-1, r=LukasKalbertodt
Manishearth Jun 29, 2020
6d70043
Rollup merge of #73716 - poliorcetics:static-keyword, r=LukasKalbertodt
Manishearth Jun 29, 2020
6b2f6c4
Rollup merge of #73752 - TyPR124:invalid-parameter-error, r=LukasKalb…
Manishearth Jun 29, 2020
fd5f4ec
Rollup merge of #73805 - poliorcetics:type-keyword, r=kennytm
Manishearth Jun 29, 2020
2fef102
Rollup merge of #73806 - Aaron1011:feature/approx-universal-upper, r=…
Manishearth Jun 29, 2020
74c734d
Rollup merge of #73812 - petrochenkov:prettyref, r=varkor
Manishearth Jun 29, 2020
994894e
Rollup merge of #73828 - nop:fix/parameter-name-help, r=estebank
Manishearth Jun 29, 2020
6267e00
Rollup merge of #73834 - oli-obk:safe_intrinsics, r=ecstatic-morse
Manishearth Jun 29, 2020
578a89e
Rollup merge of #73839 - crlf0710:snapshot_the_reality, r=Manishearth
Manishearth Jun 29, 2020
339aee7
Rollup merge of #73841 - tmiasko:print-region-graph, r=Mark-Simulacrum
Manishearth Jun 29, 2020
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
16 changes: 8 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,16 @@ exclude = [
"obj",
]

# These options are controlled from our rustc wrapper script, so turn them off
# here and have them controlled elsewhere.
[profile.dev]
debug = false
debug-assertions = false
[profile.test]
debug = false
[profile.release.package.compiler_builtins]
# The compiler-builtins crate cannot reference libcore, and it's own CI will
# verify that this is the case. This requires, however, that the crate is built
# without overflow checks and debug assertions. Forcefully disable debug
# assertions and overflow checks here which should ensure that even if these
# assertions are enabled for libstd we won't enable then for compiler_builtins
# which should ensure we still link everything correctly.
debug-assertions = false
overflow-checks = false

[profile.release.package.compiler_builtins]
# For compiler-builtins we always use a high number of codegen units.
# The goal here is to place every single intrinsic into its own object
# file to avoid symbol clashes with the system libgcc if possible. Note
Expand Down
9 changes: 6 additions & 3 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
# nightly features
#channel = "dev"

# The root location of the MUSL installation directory.
# The root location of the musl installation directory.
#musl-root = "..."

# By default the `rustc` executable is built with `-Wl,-rpath` flags on Unix
Expand Down Expand Up @@ -521,12 +521,15 @@
# only use static libraries. If unset, the target's default linkage is used.
#crt-static = false

# The root location of the MUSL installation directory. The library directory
# The root location of the musl installation directory. The library directory
# will also need to contain libunwind.a for an unwinding implementation. Note
# that this option only makes sense for MUSL targets that produce statically
# that this option only makes sense for musl targets that produce statically
# linked binaries
#musl-root = "..."

# The full path to the musl libdir.
#musl-libdir = musl-root/lib

# The root location of the `wasm32-wasi` sysroot.
#wasi-root = "..."

Expand Down
24 changes: 0 additions & 24 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,30 +101,6 @@ fn main() {
{
cmd.arg("-C").arg("panic=abort");
}

// Set various options from config.toml to configure how we're building
// code.
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
Ok(s) => {
if s == "true" {
"y"
} else {
"n"
}
}
Err(..) => "n",
};

// The compiler builtins are pretty sensitive to symbols referenced in
// libcore and such, so we never compile them with debug assertions.
//
// FIXME(rust-lang/cargo#7253) we should be doing this in `builder.rs`
// with env vars instead of doing it here in this script.
if crate_name == Some("compiler_builtins") {
cmd.arg("-C").arg("debug-assertions=no");
} else {
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
}
} else {
// FIXME(rust-lang/cargo#5754) we shouldn't be using special env vars
// here, but rather Cargo should know what flags to pass rustc itself.
Expand Down
16 changes: 8 additions & 8 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -950,14 +950,6 @@ impl<'a> Builder<'a> {
.env("RUSTC", self.out.join("bootstrap/debug/rustc"))
.env("RUSTC_REAL", self.rustc(compiler))
.env("RUSTC_STAGE", stage.to_string())
.env(
"RUSTC_DEBUG_ASSERTIONS",
if mode == Mode::Std {
self.config.rust_debug_assertions_std.to_string()
} else {
self.config.rust_debug_assertions.to_string()
},
)
.env("RUSTC_SYSROOT", &sysroot)
.env("RUSTC_LIBDIR", &libdir)
.env("RUSTDOC", self.out.join("bootstrap/debug/rustdoc"))
Expand Down Expand Up @@ -1041,6 +1033,14 @@ impl<'a> Builder<'a> {
}
};
cargo.env(profile_var("DEBUG"), debuginfo_level.to_string());
cargo.env(
profile_var("DEBUG_ASSERTIONS"),
if mode == Mode::Std {
self.config.rust_debug_assertions_std.to_string()
} else {
self.config.rust_debug_assertions.to_string()
},
);

if !mode.is_tool() {
cargo.env("RUSTC_FORCE_UNSTABLE", "1");
Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn copy_self_contained_objects(
// To do that we have to distribute musl startup objects as a part of Rust toolchain
// and link with them manually in the self-contained mode.
if target.contains("musl") {
let srcdir = builder.musl_root(target).unwrap().join("lib");
let srcdir = builder.musl_libdir(target).unwrap();
for &obj in &["crt1.o", "Scrt1.o", "rcrt1.o", "crti.o", "crtn.o"] {
copy_and_stamp(
builder,
Expand Down Expand Up @@ -266,8 +266,8 @@ pub fn std_cargo(builder: &Builder<'_>, target: Interned<String>, stage: u32, ca
// Help the libc crate compile by assisting it in finding various
// sysroot native libraries.
if target.contains("musl") {
if let Some(p) = builder.musl_root(target) {
let root = format!("native={}/lib", p.to_str().unwrap());
if let Some(p) = builder.musl_libdir(target) {
let root = format!("native={}", p.to_str().unwrap());
cargo.rustflag("-L").rustflag(&root);
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub struct Target {
pub ndk: Option<PathBuf>,
pub crt_static: Option<bool>,
pub musl_root: Option<PathBuf>,
pub musl_libdir: Option<PathBuf>,
pub wasi_root: Option<PathBuf>,
pub qemu_rootfs: Option<PathBuf>,
pub no_std: bool,
Expand Down Expand Up @@ -363,6 +364,7 @@ struct TomlTarget {
android_ndk: Option<String>,
crt_static: Option<bool>,
musl_root: Option<String>,
musl_libdir: Option<String>,
wasi_root: Option<String>,
qemu_rootfs: Option<String>,
no_std: Option<bool>,
Expand Down Expand Up @@ -631,6 +633,7 @@ impl Config {
target.linker = cfg.linker.clone().map(PathBuf::from);
target.crt_static = cfg.crt_static;
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
target.musl_libdir = cfg.musl_libdir.clone().map(PathBuf::from);
target.wasi_root = cfg.wasi_root.clone().map(PathBuf::from);
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);

Expand Down
9 changes: 9 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,15 @@ impl Build {
.map(|p| &**p)
}

/// Returns the "musl libdir" for this `target`.
fn musl_libdir(&self, target: Interned<String>) -> Option<PathBuf> {
let t = self.config.target_config.get(&target)?;
if let libdir @ Some(_) = &t.musl_libdir {
return libdir.clone();
}
self.musl_root(target).map(|root| root.join("lib"))
}

/// Returns the sysroot for the wasi target, if defined
fn wasi_root(&self, target: Interned<String>) -> Option<&Path> {
self.config.target_config.get(&target).and_then(|t| t.wasi_root.as_ref()).map(|p| &**p)
Expand Down
8 changes: 4 additions & 4 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ pub fn check(build: &mut Build) {
let target = build.config.target_config.entry(target.clone()).or_default();
target.musl_root = Some("/usr".into());
}
match build.musl_root(*target) {
Some(root) => {
if fs::metadata(root.join("lib/libc.a")).is_err() {
panic!("couldn't find libc.a in musl dir: {}", root.join("lib").display());
match build.musl_libdir(*target) {
Some(libdir) => {
if fs::metadata(libdir.join("libc.a")).is_err() {
panic!("couldn't find libc.a in musl libdir: {}", libdir.display());
}
}
None => panic!(
Expand Down
5 changes: 4 additions & 1 deletion src/liballoc/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,10 @@ impl<T: ?Sized> Box<T> {
///
/// unsafe {
/// let ptr = alloc(Layout::new::<i32>()) as *mut i32;
/// *ptr = 5;
/// // In general .write is required to avoid attempting to destruct
/// // the (uninitialized) previous contents of `ptr`, though for this
/// // simple example `*ptr = 5` would have worked as well.
/// ptr.write(5);
/// let x = Box::from_raw(ptr);
/// }
/// ```
Expand Down
38 changes: 19 additions & 19 deletions src/librustc_ast_pretty/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_ast::ast::{InlineAsmOptions, InlineAsmTemplatePiece};
use rustc_ast::attr;
use rustc_ast::ptr::P;
use rustc_ast::token::{self, BinOpToken, DelimToken, Nonterminal, Token, TokenKind};
use rustc_ast::tokenstream::{self, TokenStream, TokenTree};
use rustc_ast::tokenstream::{TokenStream, TokenTree};
use rustc_ast::util::parser::{self, AssocOp, Fixity};
use rustc_ast::util::{classify, comments};
use rustc_span::edition::Edition;
Expand Down Expand Up @@ -293,7 +293,7 @@ pub fn nonterminal_to_string(nt: &Nonterminal) -> String {
token::NtIdent(e, is_raw) => IdentPrinter::for_ast_ident(e, is_raw).to_string(),
token::NtLifetime(e) => e.to_string(),
token::NtLiteral(ref e) => expr_to_string(e),
token::NtTT(ref tree) => tt_to_string(tree.clone()),
token::NtTT(ref tree) => tt_to_string(tree),
token::NtVis(ref e) => vis_to_string(e),
}
}
Expand All @@ -314,11 +314,11 @@ pub fn expr_to_string(e: &ast::Expr) -> String {
to_string(|s| s.print_expr(e))
}

pub fn tt_to_string(tt: tokenstream::TokenTree) -> String {
pub fn tt_to_string(tt: &TokenTree) -> String {
to_string(|s| s.print_tt(tt, false))
}

pub fn tts_to_string(tokens: TokenStream) -> String {
pub fn tts_to_string(tokens: &TokenStream) -> String {
to_string(|s| s.print_tts(tokens, false))
}

Expand Down Expand Up @@ -585,7 +585,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
false,
None,
delim.to_token(),
tokens.clone(),
tokens,
true,
span,
),
Expand All @@ -594,7 +594,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
if let MacArgs::Eq(_, tokens) = &item.args {
self.space();
self.word_space("=");
self.print_tts(tokens.clone(), true);
self.print_tts(tokens, true);
}
}
}
Expand Down Expand Up @@ -635,9 +635,9 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
/// appropriate macro, transcribe back into the grammar we just parsed from,
/// and then pretty-print the resulting AST nodes (so, e.g., we print
/// expression arguments as expressions). It can be done! I think.
fn print_tt(&mut self, tt: tokenstream::TokenTree, convert_dollar_crate: bool) {
fn print_tt(&mut self, tt: &TokenTree, convert_dollar_crate: bool) {
match tt {
TokenTree::Token(ref token) => {
TokenTree::Token(token) => {
self.word(token_to_string_ext(&token, convert_dollar_crate));
if let token::DocComment(..) = token.kind {
self.hardbreak()
Expand All @@ -648,7 +648,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
None,
false,
None,
delim,
*delim,
tts,
convert_dollar_crate,
dspan.entire(),
Expand All @@ -657,14 +657,14 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
}
}

fn print_tts(&mut self, tts: tokenstream::TokenStream, convert_dollar_crate: bool) {
let mut iter = tts.into_trees().peekable();
fn print_tts(&mut self, tts: &TokenStream, convert_dollar_crate: bool) {
let mut iter = tts.trees().peekable();
while let Some(tt) = iter.next() {
let show_space =
if let Some(next) = iter.peek() { tt_prepend_space(next, &tt) } else { false };
self.print_tt(tt, convert_dollar_crate);
if show_space {
self.space();
self.print_tt(&tt, convert_dollar_crate);
if let Some(next) = iter.peek() {
if tt_prepend_space(next, &tt) {
self.space();
}
}
}
}
Expand All @@ -675,7 +675,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
has_bang: bool,
ident: Option<Ident>,
delim: DelimToken,
tts: TokenStream,
tts: &TokenStream,
convert_dollar_crate: bool,
span: Span,
) {
Expand Down Expand Up @@ -1253,7 +1253,7 @@ impl<'a> State<'a> {
has_bang,
Some(item.ident),
macro_def.body.delim(),
macro_def.body.inner_tokens(),
&macro_def.body.inner_tokens(),
true,
item.span,
);
Expand Down Expand Up @@ -1577,7 +1577,7 @@ impl<'a> State<'a> {
true,
None,
m.args.delim(),
m.args.inner_tokens(),
&m.args.inner_tokens(),
true,
m.span(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/log_syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn expand_log_syntax<'cx>(
sp: rustc_span::Span,
tts: TokenStream,
) -> Box<dyn base::MacResult + 'cx> {
println!("{}", pprust::tts_to_string(tts));
println!("{}", pprust::tts_to_string(&tts));

// any so that `log_syntax` can be invoked as an expression and item.
base::DummyResult::any_valid(sp)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub fn expand_stringify(
tts: TokenStream,
) -> Box<dyn base::MacResult + 'static> {
let sp = cx.with_def_site_ctxt(sp);
let s = pprust::tts_to_string(tts);
let s = pprust::tts_to_string(&tts);
base::MacEager::expr(cx.expr_str(sp, Symbol::intern(&s)))
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_expand/mbe/macro_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ fn generic_extension<'cx>(
let sess = cx.parse_sess;

if cx.trace_macros() {
let msg = format!("expanding `{}! {{ {} }}`", name, pprust::tts_to_string(arg.clone()));
let msg = format!("expanding `{}! {{ {} }}`", name, pprust::tts_to_string(&arg));
trace_macros_note(&mut cx.expansions, sp, msg);
}

Expand Down Expand Up @@ -300,7 +300,7 @@ fn generic_extension<'cx>(
}

if cx.trace_macros() {
let msg = format!("to `{}`", pprust::tts_to_string(tts.clone()));
let msg = format!("to `{}`", pprust::tts_to_string(&tts));
trace_macros_note(&mut cx.expansions, sp, msg);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_expand/proc_macro_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl server::TokenStream for Rustc<'_> {
)
}
fn to_string(&mut self, stream: &Self::TokenStream) -> String {
pprust::tts_to_string(stream.clone())
pprust::tts_to_string(stream)
}
fn from_token_tree(
&mut self,
Expand Down
1 change: 0 additions & 1 deletion src/librustc_interface/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ fn test_debugging_options_tracking_hash() {
untracked!(print_link_args, true);
untracked!(print_llvm_passes, true);
untracked!(print_mono_items, Some(String::from("abc")));
untracked!(print_region_graph, true);
untracked!(print_type_sizes, true);
untracked!(query_dep_graph, true);
untracked!(query_stats, true);
Expand Down
4 changes: 3 additions & 1 deletion src/librustc_mir/borrow_check/diagnostics/region_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if self.regioncx.universal_regions().is_universal_region(r) {
Some(r)
} else {
let upper_bound = self.regioncx.universal_upper_bound(r);
// We just want something nameable, even if it's not
// actually an upper bound.
let upper_bound = self.regioncx.approx_universal_upper_bound(r);

if self.regioncx.upper_bound_in_region_scc(r, upper_bound) {
self.to_error_region_vid(upper_bound)
Expand Down
Loading