Skip to content

Commit

Permalink
Auto merge of #76804 - tmandry:rollup-nwntt3q, r=tmandry
Browse files Browse the repository at this point in the history
Rollup of 16 pull requests

Successful merges:

 - #75026 (Add array_windows fn)
 - #76642 (Do not lint ignored private doc tests)
 - #76719 (Change error message for ty param in const)
 - #76721 (Use intra-doc links in `core::mem`)
 - #76728 (Add a comment why `extern crate` is necessary for rustdoc)
 - #76735 (Remove unnecessary `clone()`s in bootstrap)
 - #76741 (Avoid printing dry run timings)
 - #76747 (Add missing code examples in libcore)
 - #76756 (fix a couple of stylistic clippy warnings)
 - #76758 ([fuchsia] Propagate the userspace UTC clock)
 - #76759 (Fix stabilization marker for future_readiness_fns)
 - #76760 (don't lazily evaluate some trivial values for Option::None replacements (clippy::unnecessary_lazy_evaluations))
 - #76764 (Update books)
 - #76775 (Strip a single leading tab when rendering dataflow diffs)
 - #76778 (Simplify iter fuse struct doc)
 - #76794 (Make graphviz font configurable)

Failed merges:

r? `@ghost`
  • Loading branch information
bors committed Sep 16, 2020
2 parents ff806b8 + 3bf66ae commit 285fc7d
Show file tree
Hide file tree
Showing 54 changed files with 450 additions and 164 deletions.
17 changes: 10 additions & 7 deletions compiler/rustc_graphviz/src/lib.rs
Expand Up @@ -591,14 +591,14 @@ pub trait GraphWalk<'a> {
fn target(&'a self, edge: &Self::Edge) -> Self::Node;
}

#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum RenderOption {
NoEdgeLabels,
NoNodeLabels,
NoEdgeStyles,
NoNodeStyles,

Monospace,
Fontname(String),
DarkTheme,
}

Expand Down Expand Up @@ -633,11 +633,14 @@ where
// Global graph properties
let mut graph_attrs = Vec::new();
let mut content_attrs = Vec::new();
if options.contains(&RenderOption::Monospace) {
let font = r#"fontname="Courier, monospace""#;
graph_attrs.push(font);
content_attrs.push(font);
};
let font;
if let Some(fontname) = options.iter().find_map(|option| {
if let RenderOption::Fontname(fontname) = option { Some(fontname) } else { None }
}) {
font = format!(r#"fontname="{}""#, fontname);
graph_attrs.push(&font[..]);
content_attrs.push(&font[..]);
}
if options.contains(&RenderOption::DarkTheme) {
graph_attrs.push(r#"bgcolor="black""#);
content_attrs.push(r#"color="white""#);
Expand Down
Expand Up @@ -85,7 +85,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {

debug!("try_report_named_anon_conflict: ret ty {:?}", ty);
if sub == &ty::ReStatic
&& v.0.into_iter().find(|t| t.span.desugaring_kind().is_none()).is_some()
&& v.0.into_iter().any(|t| t.span.desugaring_kind().is_none())
{
// If the failure is due to a `'static` requirement coming from a `dyn` or
// `impl` Trait that *isn't* caused by `async fn` desugaring, handle this case
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/builtin.rs
Expand Up @@ -961,7 +961,7 @@ fn warn_if_doc(cx: &EarlyContext<'_>, node_span: Span, node_kind: &str, attrs: &
continue;
}

let span = sugared_span.take().unwrap_or_else(|| attr.span);
let span = sugared_span.take().unwrap_or(attr.span);

if attr.is_doc_comment() || cx.sess().check_name(attr, sym::doc) {
cx.struct_span_lint(UNUSED_DOC_COMMENTS, span, |lint| {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_metadata/src/native_libs.rs
Expand Up @@ -170,7 +170,7 @@ impl Collector<'tcx> {
feature_err(
&self.tcx.sess.parse_sess,
sym::static_nobundle,
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
span.unwrap_or(rustc_span::DUMMY_SP),
"kind=\"static-nobundle\" is unstable",
)
.emit();
Expand All @@ -179,7 +179,7 @@ impl Collector<'tcx> {
feature_err(
&self.tcx.sess.parse_sess,
sym::raw_dylib,
span.unwrap_or_else(|| rustc_span::DUMMY_SP),
span.unwrap_or(rustc_span::DUMMY_SP),
"kind=\"raw-dylib\" is unstable",
)
.emit();
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Expand Up @@ -273,10 +273,10 @@ pub trait PrettyPrinter<'tcx>:
}

match self.tcx().trimmed_def_paths(LOCAL_CRATE).get(&def_id) {
None => return Ok((self, false)),
None => Ok((self, false)),
Some(symbol) => {
self.write_str(&symbol.as_str())?;
return Ok((self, true));
Ok((self, true))
}
}
}
Expand Down
Expand Up @@ -387,7 +387,7 @@ impl<'a, 'tcx> MirBorrowckCtxt<'a, 'tcx> {
if let ReturnConstraint::ClosureUpvar(upvar) = kind {
let def_id = match self.regioncx.universal_regions().defining_ty {
DefiningTy::Closure(def_id, _) => def_id,
ty @ _ => bug!("unexpected DefiningTy {:?}", ty),
ty => bug!("unexpected DefiningTy {:?}", ty),
};

let upvar_def_span = self.infcx.tcx.hir().span(upvar);
Expand Down
3 changes: 2 additions & 1 deletion compiler/rustc_mir/src/dataflow/framework/engine.rs
Expand Up @@ -306,7 +306,8 @@ where
let mut buf = Vec::new();

let graphviz = graphviz::Formatter::new(body, def_id, results, style);
let mut render_opts = vec![dot::RenderOption::Monospace];
let mut render_opts =
vec![dot::RenderOption::Fontname(tcx.sess.opts.debugging_opts.graphviz_font.clone())];
if tcx.sess.opts.debugging_opts.graphviz_dark_mode {
render_opts.push(dot::RenderOption::DarkTheme);
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/dataflow/framework/graphviz.rs
Expand Up @@ -578,7 +578,7 @@ where
return String::new();
}

let re = Regex::new("\u{001f}([+-])").unwrap();
let re = Regex::new("\t?\u{001f}([+-])").unwrap();

let raw_diff = format!("{:#?}", DebugDiffWithAdapter { new, old, ctxt });

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_mir/src/transform/instcombine.rs
Expand Up @@ -126,7 +126,7 @@ impl OptimizationFinder<'b, 'tcx> {
}
}

return None;
None
}
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_mir/src/util/graphviz.rs
Expand Up @@ -55,9 +55,9 @@ where
writeln!(w, "{} {}Mir_{} {{", kind, cluster, def_name)?;

// Global graph properties
let font = r#"fontname="Courier, monospace""#;
let mut graph_attrs = vec![font];
let mut content_attrs = vec![font];
let font = format!(r#"fontname="{}""#, tcx.sess.opts.debugging_opts.graphviz_font);
let mut graph_attrs = vec![&font[..]];
let mut content_attrs = vec![&font[..]];

let dark_mode = tcx.sess.opts.debugging_opts.graphviz_dark_mode;
if dark_mode {
Expand Down
16 changes: 12 additions & 4 deletions compiler/rustc_resolve/src/diagnostics.rs
Expand Up @@ -466,7 +466,7 @@ impl<'a> Resolver<'a> {
);
err
}
ResolutionError::ParamInNonTrivialAnonConst(name) => {
ResolutionError::ParamInNonTrivialAnonConst { name, is_type } => {
let mut err = self.session.struct_span_err(
span,
"generic parameters must not be used inside of non trivial constant values",
Expand All @@ -478,9 +478,17 @@ impl<'a> Resolver<'a> {
name
),
);
err.help(
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants", name)
);

if is_type {
err.note("type parameters are currently not permitted in anonymous constants");
} else {
err.help(
&format!("it is currently only allowed to use either `{0}` or `{{ {0} }}` as generic constants",
name
)
);
}

err
}
ResolutionError::SelfInTyParamDefault => {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Expand Up @@ -1534,7 +1534,7 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
}
};

let lifetime_names: Vec<_> = lifetime_names.into_iter().collect();
let lifetime_names: Vec<_> = lifetime_names.iter().collect();
match (&lifetime_names[..], snippet.as_deref()) {
([name], Some("&")) => {
suggest_existing(err, &name.as_str()[..], &|name| format!("&{} ", name));
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_resolve/src/lib.rs
Expand Up @@ -221,7 +221,7 @@ enum ResolutionError<'a> {
/// generic parameters must not be used inside of non trivial constant values.
///
/// This error is only emitted when using `min_const_generics`.
ParamInNonTrivialAnonConst(Symbol),
ParamInNonTrivialAnonConst { name: Symbol, is_type: bool },
/// Error E0735: type parameters with a default cannot use `Self`
SelfInTyParamDefault,
/// Error E0767: use of unreachable label
Expand Down Expand Up @@ -2638,9 +2638,10 @@ impl<'a> Resolver<'a> {
if record_used {
self.report_error(
span,
ResolutionError::ParamInNonTrivialAnonConst(
rib_ident.name,
),
ResolutionError::ParamInNonTrivialAnonConst {
name: rib_ident.name,
is_type: true,
},
);
}
return Res::Err;
Expand Down Expand Up @@ -2718,7 +2719,10 @@ impl<'a> Resolver<'a> {
if record_used {
self.report_error(
span,
ResolutionError::ParamInNonTrivialAnonConst(rib_ident.name),
ResolutionError::ParamInNonTrivialAnonConst {
name: rib_ident.name,
is_type: false,
},
);
}
return Res::Err;
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_session/src/config.rs
Expand Up @@ -1762,6 +1762,10 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
debugging_opts.symbol_mangling_version = SymbolManglingVersion::V0;
}

if let Ok(graphviz_font) = std::env::var("RUSTC_GRAPHVIZ_FONT") {
debugging_opts.graphviz_font = graphviz_font;
}

if !cg.embed_bitcode {
match cg.lto {
LtoCli::No | LtoCli::Unspecified => {}
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_session/src/options.rs
Expand Up @@ -911,6 +911,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"set the optimization fuel quota for a crate"),
graphviz_dark_mode: bool = (false, parse_bool, [UNTRACKED],
"use dark-themed colors in graphviz output (default: no)"),
graphviz_font: String = ("Courier, monospace".to_string(), parse_string, [UNTRACKED],
"use the given `fontname` in graphviz output; can be overridden by setting \
environment variable `RUSTC_GRAPHVIZ_FONT` (default: `Courier, monospace`)"),
hir_stats: bool = (false, parse_bool, [UNTRACKED],
"print some statistics about AST and HIR (default: no)"),
human_readable_cgu_names: bool = (false, parse_bool, [TRACKED],
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_trait_selection/src/traits/coherence.rs
Expand Up @@ -182,7 +182,7 @@ fn overlap_within_probe(
}

if !skip_leak_check.is_yes() {
if let Err(_) = infcx.leak_check(true, snapshot) {
if infcx.leak_check(true, snapshot).is_err() {
debug!("overlap: leak check failed");
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_typeck/src/check/_match.rs
Expand Up @@ -164,7 +164,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
// If all the obligations hold (or there are no obligations) the tail expression
// we can suggest to return a boxed trait object instead of an opaque type.
if suggest_box { self.ret_type_span.clone() } else { None }
if suggest_box { self.ret_type_span } else { None }
}
_ => None,
};
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/expr.rs
Expand Up @@ -1243,10 +1243,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if check_completeness && !error_happened && !remaining_fields.is_empty() {
let no_accessible_remaining_fields = remaining_fields
.iter()
.filter(|(_, (_, field))| {
.find(|(_, (_, field))| {
field.vis.is_accessible_from(tcx.parent_module(expr_id).to_def_id(), tcx)
})
.next()
.is_none();

if no_accessible_remaining_fields {
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_typeck/src/check/pat.rs
Expand Up @@ -1141,10 +1141,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
} else if !etc && !unmentioned_fields.is_empty() {
let no_accessible_unmentioned_fields = unmentioned_fields
.iter()
.filter(|(field, _)| {
.find(|(field, _)| {
field.vis.is_accessible_from(tcx.parent_module(pat.hir_id).to_def_id(), tcx)
})
.next()
.is_none();

if no_accessible_unmentioned_fields {
Expand Down
1 change: 1 addition & 0 deletions library/alloc/src/lib.rs
Expand Up @@ -76,6 +76,7 @@
#![cfg_attr(test, feature(test))]
#![feature(allocator_api)]
#![feature(array_chunks)]
#![feature(array_windows)]
#![feature(allow_internal_unstable)]
#![feature(arbitrary_self_types)]
#![feature(box_patterns)]
Expand Down
2 changes: 2 additions & 0 deletions library/alloc/src/slice.rs
Expand Up @@ -97,6 +97,8 @@ pub use core::slice::check_range;
pub use core::slice::ArrayChunks;
#[unstable(feature = "array_chunks", issue = "74985")]
pub use core::slice::ArrayChunksMut;
#[unstable(feature = "array_windows", issue = "75027")]
pub use core::slice::ArrayWindows;
#[stable(feature = "slice_get_slice", since = "1.28.0")]
pub use core::slice::SliceIndex;
#[stable(feature = "from_ref", since = "1.28.0")]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/future/mod.rs
Expand Up @@ -21,9 +21,9 @@ pub use self::future::Future;
#[unstable(feature = "into_future", issue = "67644")]
pub use into_future::IntoFuture;

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
pub use pending::{pending, Pending};
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
pub use ready::{ready, Ready};

#[unstable(feature = "future_poll_fn", issue = "72302")]
Expand Down
12 changes: 6 additions & 6 deletions library/core/src/future/pending.rs
Expand Up @@ -11,7 +11,7 @@ use crate::task::{Context, Poll};
/// documentation for more.
///
/// [`pending`]: fn.pending.html
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Pending<T> {
_data: marker::PhantomData<T>,
Expand All @@ -31,12 +31,12 @@ pub struct Pending<T> {
/// unreachable!();
/// # }
/// ```
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
pub fn pending<T>() -> Pending<T> {
Pending { _data: marker::PhantomData }
}

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Future for Pending<T> {
type Output = T;

Expand All @@ -45,17 +45,17 @@ impl<T> Future for Pending<T> {
}
}

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Unpin for Pending<T> {}

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Debug for Pending<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Pending").finish()
}
}

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Clone for Pending<T> {
fn clone(&self) -> Self {
pending()
Expand Down
8 changes: 4 additions & 4 deletions library/core/src/future/ready.rs
Expand Up @@ -8,15 +8,15 @@ use crate::task::{Context, Poll};
/// documentation for more.
///
/// [`ready`]: fn.ready.html
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
#[derive(Debug, Clone)]
#[must_use = "futures do nothing unless you `.await` or poll them"]
pub struct Ready<T>(Option<T>);

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Unpin for Ready<T> {}

#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
impl<T> Future for Ready<T> {
type Output = T;

Expand All @@ -42,7 +42,7 @@ impl<T> Future for Ready<T> {
/// assert_eq!(a.await, 1);
/// # }
/// ```
#[stable(feature = "future_readiness_fns", since = "1.47.0")]
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
pub fn ready<T>(t: T) -> Ready<T> {
Ready(Some(t))
}
7 changes: 2 additions & 5 deletions library/core/src/iter/adapters/fuse.rs
Expand Up @@ -9,11 +9,8 @@ use crate::ops::Try;
/// An iterator that yields `None` forever after the underlying iterator
/// yields `None` once.
///
/// This `struct` is created by the [`fuse`] method on [`Iterator`]. See its
/// documentation for more.
///
/// [`fuse`]: trait.Iterator.html#method.fuse
/// [`Iterator`]: trait.Iterator.html
/// This `struct` is created by [`Iterator::fuse`]. See its documentation
/// for more.
#[derive(Clone, Debug)]
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 285fc7d

Please sign in to comment.