Skip to content

Rollup of 9 pull requests #83426

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 27 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b24902e
Run analyses before thir-tree dumps
osa1 Mar 12, 2021
f398a49
Add test for io::Error's size.
m-ou-se Mar 21, 2021
2da9856
Add internal io::Error::new_const tot avoid allocations.
m-ou-se Mar 21, 2021
9678362
Add test for io::Error::new_const.
m-ou-se Mar 21, 2021
7b71719
Use io::Error::new_const everywhere to avoid allocations.
m-ou-se Mar 21, 2021
6bbcc5b
Fix typos
m-ou-se Mar 21, 2021
74d7731
2229 migration: Don't try resolve regions before writeback
arora-aman Mar 22, 2021
219603a
Only enable assert_dep_graph when query-dep-graph is enabled.
cjgillot Mar 20, 2021
45583e5
Change `-W help` to display edition level.
ehuss Mar 22, 2021
1aad7e7
Err if the debugging options are not passed.
cjgillot Mar 22, 2021
494e29d
Fix codeblock tooltip position
GuillaumeGomez Mar 22, 2021
6c80deb
Add GUI test to enforce tooltip position
GuillaumeGomez Mar 22, 2021
4fa187f
Slight visual improvements to warning boxes in the docs
wooster0 Mar 23, 2021
5e81325
Fix sidebar trait items sort
GuillaumeGomez Mar 12, 2021
7245903
Add test to enforce sidebar trait items order
GuillaumeGomez Mar 12, 2021
801ee83
Use &str instead of String
GuillaumeGomez Mar 23, 2021
31447f6
Fix comment.
cjgillot Mar 23, 2021
1d4b447
Update cargo
ehuss Mar 23, 2021
e26635a
Rollup merge of #83050 - osa1:issue83048, r=matthewjasper
Dylan-DPC Mar 23, 2021
107e0dd
Rollup merge of #83051 - GuillaumeGomez:sidebar-trait-items-order, r=…
Dylan-DPC Mar 23, 2021
e1ca3f0
Rollup merge of #83313 - cjgillot:assert, r=michaelwoerister
Dylan-DPC Mar 23, 2021
ac33062
Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisa
Dylan-DPC Mar 23, 2021
0c174bf
Rollup merge of #83364 - sexxi-goose:fix-83176, r=nikomatsakis
Dylan-DPC Mar 23, 2021
f8c6924
Rollup merge of #83392 - ehuss:w-help-edition, r=varkor
Dylan-DPC Mar 23, 2021
d9dfcdc
Rollup merge of #83393 - GuillaumeGomez:codeblock-tooltip-position, r…
Dylan-DPC Mar 23, 2021
e54a4c7
Rollup merge of #83405 - r00ster91:deprecated_emoji, r=GuillaumeGomez
Dylan-DPC Mar 23, 2021
282cf89
Rollup merge of #83418 - ehuss:update-cargo, r=ehuss
Dylan-DPC Mar 23, 2021
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
45 changes: 31 additions & 14 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,10 @@ dependencies = [
"cargo-platform",
"cargo-test-macro",
"cargo-test-support",
"cargo-util",
"clap",
"core-foundation",
"crates-io",
"crossbeam-utils 0.8.0",
"crypto-hash",
"curl",
"curl-sys",
"env_logger 0.8.1",
Expand All @@ -313,7 +312,6 @@ dependencies = [
"libgit2-sys",
"log",
"memchr",
"miow 0.3.6",
"num_cpus",
"opener",
"openssl",
Expand All @@ -322,12 +320,10 @@ dependencies = [
"rand 0.8.3",
"rustc-workspace-hack",
"rustfix",
"same-file",
"semver 0.10.0",
"serde",
"serde_ignored",
"serde_json",
"shell-escape",
"strip-ansi-escapes",
"tar",
"tempfile",
Expand Down Expand Up @@ -396,8 +392,9 @@ version = "0.1.0"
name = "cargo-test-support"
version = "0.1.0"
dependencies = [
"cargo",
"anyhow",
"cargo-test-macro",
"cargo-util",
"filetime",
"flate2",
"git2",
Expand All @@ -410,6 +407,26 @@ dependencies = [
"url 2.1.1",
]

[[package]]
name = "cargo-util"
version = "0.1.0"
dependencies = [
"anyhow",
"core-foundation",
"crypto-hash",
"filetime",
"hex 0.4.2",
"jobserver",
"libc",
"log",
"miow 0.3.6",
"same-file",
"shell-escape",
"tempfile",
"walkdir",
"winapi 0.3.9",
]

[[package]]
name = "cargo_metadata"
version = "0.8.2"
Expand Down Expand Up @@ -2765,9 +2782,9 @@ checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086"

[[package]]
name = "proc-macro2"
version = "1.0.19"
version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04f5f085b5d71e2188cb8271e5da0161ad52c3f227a661a3c135fdf28e258b12"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
dependencies = [
"unicode-xid",
]
Expand Down Expand Up @@ -4793,18 +4810,18 @@ dependencies = [

[[package]]
name = "serde"
version = "1.0.118"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06c64263859d87aa2eb554587e2d23183398d617427327cf2b3d0ed8c69e4800"
checksum = "558dc50e1a5a5fa7112ca2ce4effcb321b0300c0d4ccf0776a9f60cd89031171"
dependencies = [
"serde_derive",
]

[[package]]
name = "serde_derive"
version = "1.0.118"
version = "1.0.125"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df"
checksum = "b093b7a2bb58203b5da3056c05b4ec1fed827dcfdb37347a8841695263b3d06d"
dependencies = [
"proc-macro2",
"quote",
Expand Down Expand Up @@ -5100,9 +5117,9 @@ dependencies = [

[[package]]
name = "syn"
version = "1.0.38"
version = "1.0.64"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e69abc24912995b3038597a7a593be5053eb0fb44f3cc5beec0deb421790c1f4"
checksum = "3fd9d1e9976102a03c542daa2eff1b43f9d72306342f3f8b3ed5fb8908195d6f"
dependencies = [
"proc-macro2",
"quote",
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,12 @@ Available lint options:
let print_lints = |lints: Vec<&Lint>| {
for lint in lints {
let name = lint.name_lower().replace("_", "-");
println!(" {} {:7.7} {}", padded(&name), lint.default_level.as_str(), lint.desc);
println!(
" {} {:7.7} {}",
padded(&name),
lint.default_level(sess.edition()).as_str(),
lint.desc
);
}
println!("\n");
};
Expand Down
53 changes: 30 additions & 23 deletions compiler/rustc_driver/src/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,21 +471,6 @@ pub fn print_after_hir_lowering<'tcx>(
format!("{:#?}", krate)
}),

ThirTree => {
let mut out = String::new();
abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
debug!("pretty printing THIR tree");
for did in tcx.body_owners() {
let hir = tcx.hir();
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
let arena = thir::Arena::default();
let thir =
thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
}
out
}

_ => unreachable!(),
};

Expand All @@ -501,18 +486,40 @@ fn print_with_analysis(
ppm: PpMode,
ofile: Option<&Path>,
) -> Result<(), ErrorReported> {
let mut out = Vec::new();

tcx.analysis(LOCAL_CRATE)?;

match ppm {
Mir => write_mir_pretty(tcx, None, &mut out).unwrap(),
MirCFG => write_mir_graphviz(tcx, None, &mut out).unwrap(),
let out = match ppm {
Mir => {
let mut out = Vec::new();
write_mir_pretty(tcx, None, &mut out).unwrap();
String::from_utf8(out).unwrap()
}

MirCFG => {
let mut out = Vec::new();
write_mir_graphviz(tcx, None, &mut out).unwrap();
String::from_utf8(out).unwrap()
}

ThirTree => {
let mut out = String::new();
abort_on_err(rustc_typeck::check_crate(tcx), tcx.sess);
debug!("pretty printing THIR tree");
for did in tcx.body_owners() {
let hir = tcx.hir();
let body = hir.body(hir.body_owned_by(hir.local_def_id_to_hir_id(did)));
let arena = thir::Arena::default();
let thir =
thir::build_thir(tcx, ty::WithOptConstParam::unknown(did), &arena, &body.value);
let _ = writeln!(out, "{:?}:\n{:#?}\n", did, thir);
}
out
}

_ => unreachable!(),
}
};

let out = std::str::from_utf8(&out).unwrap();
write_or_print(out, ofile);
write_or_print(&out, ofile);

Ok(())
}
4 changes: 4 additions & 0 deletions compiler/rustc_incremental/src/assert_dep_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub fn assert_dep_graph(tcx: TyCtxt<'_>) {
dump_graph(tcx);
}

if !tcx.sess.opts.debugging_opts.query_dep_graph {
return;
}

// if the `rustc_attrs` feature is not enabled, then the
// attributes we are interested in cannot be present anyway, so
// skip the walk.
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_incremental/src/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ impl Assertion {
}

pub fn check_dirty_clean_annotations(tcx: TyCtxt<'_>) {
if !tcx.sess.opts.debugging_opts.query_dep_graph {
return;
}

// can't add `#[rustc_dirty]` etc without opting in to this feature
if !tcx.features().rustc_attrs {
return;
Expand Down
20 changes: 20 additions & 0 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ impl CheckAttrVisitor<'tcx> {
self.check_naked(hir_id, attr, span, target)
} else if self.tcx.sess.check_name(attr, sym::rustc_legacy_const_generics) {
self.check_rustc_legacy_const_generics(&attr, span, target, item)
} else if self.tcx.sess.check_name(attr, sym::rustc_clean)
|| self.tcx.sess.check_name(attr, sym::rustc_dirty)
|| self.tcx.sess.check_name(attr, sym::rustc_if_this_changed)
|| self.tcx.sess.check_name(attr, sym::rustc_then_this_would_need)
{
self.check_rustc_dirty_clean(&attr)
} else {
// lint-only checks
if self.tcx.sess.check_name(attr, sym::cold) {
Expand Down Expand Up @@ -1012,6 +1018,20 @@ impl CheckAttrVisitor<'tcx> {
}
}

/// Checks that the dep-graph debugging attributes are only present when the query-dep-graph
/// option is passed to the compiler.
fn check_rustc_dirty_clean(&self, attr: &Attribute) -> bool {
if self.tcx.sess.opts.debugging_opts.query_dep_graph {
true
} else {
self.tcx
.sess
.struct_span_err(attr.span, "attribute requires -Z query-dep-graph to be enabled")
.emit();
false
}
}

/// Checks if `#[link_section]` is applied to a function or static.
fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,7 @@ impl PpMode {

pub fn needs_analysis(&self) -> bool {
use PpMode::*;
matches!(*self, Mir | MirCFG)
matches!(*self, Mir | MirCFG | ThirTree)
}
}

Expand Down
19 changes: 2 additions & 17 deletions compiler/rustc_typeck/src/check/upvar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
//! then mean that all later passes would have to check for these figments
//! and report an error, and it just seems like more mess in the end.)

use super::writeback::Resolver;
use super::FnCtxt;

use crate::expr_use_visitor as euv;
Expand All @@ -42,7 +41,6 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_infer::infer::UpvarRegion;
use rustc_middle::hir::place::{Place, PlaceBase, PlaceWithHirId, Projection, ProjectionKind};
use rustc_middle::mir::FakeReadCause;
use rustc_middle::ty::fold::TypeFoldable;
use rustc_middle::ty::{self, Ty, TyCtxt, TypeckResults, UpvarSubsts};
use rustc_session::lint;
use rustc_span::sym;
Expand Down Expand Up @@ -167,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {

let closure_hir_id = self.tcx.hir().local_def_id_to_hir_id(local_def_id);
if should_do_migration_analysis(self.tcx, closure_hir_id) {
self.perform_2229_migration_anaysis(closure_def_id, capture_clause, span, body);
self.perform_2229_migration_anaysis(closure_def_id, capture_clause, span);
}

// We now fake capture information for all variables that are mentioned within the closure
Expand Down Expand Up @@ -467,13 +465,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
closure_def_id: DefId,
capture_clause: hir::CaptureBy,
span: Span,
body: &'tcx hir::Body<'tcx>,
) {
let need_migrations = self.compute_2229_migrations(
closure_def_id,
span,
capture_clause,
body,
self.typeck_results.borrow().closure_min_captures.get(&closure_def_id),
);

Expand Down Expand Up @@ -511,19 +507,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
closure_def_id: DefId,
closure_span: Span,
closure_clause: hir::CaptureBy,
body: &'tcx hir::Body<'tcx>,
min_captures: Option<&ty::RootVariableMinCaptureList<'tcx>>,
) -> Vec<hir::HirId> {
fn resolve_ty<T: TypeFoldable<'tcx>>(
fcx: &FnCtxt<'_, 'tcx>,
span: Span,
body: &'tcx hir::Body<'tcx>,
ty: T,
) -> T {
let mut resolver = Resolver::new(fcx, &span, body);
ty.fold_with(&mut resolver)
}

let upvars = if let Some(upvars) = self.tcx.upvars_mentioned(closure_def_id) {
upvars
} else {
Expand All @@ -533,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let mut need_migrations = Vec::new();

for (&var_hir_id, _) in upvars.iter() {
let ty = resolve_ty(self, closure_span, body, self.node_ty(var_hir_id));
let ty = self.infcx.resolve_vars_if_possible(self.node_ty(var_hir_id));

if !ty.needs_drop(self.tcx, self.tcx.param_env(closure_def_id.expect_local())) {
continue;
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_typeck/src/check/writeback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ impl Locatable for hir::HirId {

/// The Resolver. This is the type folding engine that detects
/// unresolved types and so forth.
crate struct Resolver<'cx, 'tcx> {
struct Resolver<'cx, 'tcx> {
tcx: TyCtxt<'tcx>,
infcx: &'cx InferCtxt<'cx, 'tcx>,
span: &'cx dyn Locatable,
Expand All @@ -686,7 +686,7 @@ crate struct Resolver<'cx, 'tcx> {
}

impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
crate fn new(
fn new(
fcx: &'cx FnCtxt<'cx, 'tcx>,
span: &'cx dyn Locatable,
body: &'tcx hir::Body<'tcx>,
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1036,7 +1036,7 @@ impl fmt::Display for NulError {
impl From<NulError> for io::Error {
/// Converts a [`NulError`] into a [`io::Error`].
fn from(_: NulError) -> io::Error {
io::Error::new(io::ErrorKind::InvalidInput, "data provided contains a nul byte")
io::Error::new_const(io::ErrorKind::InvalidInput, &"data provided contains a nul byte")
}
}

Expand Down
5 changes: 4 additions & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2188,7 +2188,10 @@ impl DirBuilder {
match path.parent() {
Some(p) => self.create_dir_all(p)?,
None => {
return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree"));
return Err(io::Error::new_const(
io::ErrorKind::Other,
&"failed to create whole tree",
));
}
}
match self.inner.mkdir(path) {
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/io/buffered/bufwriter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ impl<W: Write> BufWriter<W> {

match r {
Ok(0) => {
return Err(Error::new(
return Err(Error::new_const(
ErrorKind::WriteZero,
"failed to write the buffered data",
&"failed to write the buffered data",
));
}
Ok(n) => guard.consume(n),
Expand Down
Loading