Skip to content

Commit

Permalink
Auto merge of #68174 - JohnTitor:rollup-ix4amrj, r=JohnTitor
Browse files Browse the repository at this point in the history
Rollup of 8 pull requests

Successful merges:

 - #67313 (Document more use cases of dataflow)
 - #67959 (rustdoc: improve stability mark arrows)
 - #68097 (Specify units for test timeout environment variables)
 - #68135 (restore some rustc_parse visibilities for rustfmt)
 - #68145 (Expose `context::CheckLintNameResult`)
 - #68156 (Fix crate paths in comments)
 - #68157 (Clean up E0186 explanation)
 - #68161 (Fix system call docs for time::Instant)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jan 13, 2020
2 parents e82febc + 87bdc8e commit af95804
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 19 deletions.
18 changes: 17 additions & 1 deletion src/librustc_error_codes/error_codes/E0186.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ An associated function for a trait was defined to be a method (i.e., to take a
`self` parameter), but an implementation of the trait declared the same function
to be static.

Here's an example of this error:
Erroneous code example:

```compile_fail,E0186
trait Foo {
Expand All @@ -17,3 +17,19 @@ impl Foo for Bar {
fn foo() {}
}
```

When a type implements a trait's associated function, it has to use the same
signature. So in this case, since `Foo::foo` takes `self` as argument and
does not return anything, its implementation on `Bar` should be the same:

```
trait Foo {
fn foo(&self);
}
struct Bar;
impl Foo for Bar {
fn foo(&self) {} // ok!
}
```
3 changes: 2 additions & 1 deletion src/librustc_feature/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
//! # Feature gates
//!
//! This crate declares the set of past and present unstable features in the compiler.
//! Feature gate checking itself is done in `libsyntax/feature_gate/check.rs` at the moment.
//! Feature gate checking itself is done in `librustc_ast_passes/feature_gate.rs`
//! at the moment.
//!
//! Features are enabled in programs via the crate-level attributes of
//! `#![feature(...)]` with a comma-separated list of features.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ declare_lint! {
}

declare_lint_pass!(
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `feature_gate.rs`.
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `librustc_feature/active.rs`.
IncompleteFeatures => [INCOMPLETE_FEATURES]
);

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_lint/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use unused::*;

/// Useful for other parts of the compiler / Clippy.
pub use builtin::SoftLints;
pub use context::{EarlyContext, LateContext, LintContext, LintStore};
pub use context::{CheckLintNameResult, EarlyContext, LateContext, LintContext, LintStore};
pub use early::check_ast_crate;
pub use late::check_crate;
pub use passes::{EarlyLintPass, LateLintPass};
Expand Down
24 changes: 23 additions & 1 deletion src/librustc_mir/dataflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,26 @@ pub trait BottomValue {
const BOTTOM_VALUE: bool;

/// Merges `in_set` into `inout_set`, returning `true` if `inout_set` changed.
///
/// It is almost certainly wrong to override this, since it automatically applies
/// * `inout_set & in_set` if `BOTTOM_VALUE == true`
/// * `inout_set | in_set` if `BOTTOM_VALUE == false`
///
/// This means that if a bit is not `BOTTOM_VALUE`, it is propagated into all target blocks.
/// For clarity, the above statement again from a different perspective:
/// A bit in the block's entry set is `!BOTTOM_VALUE` if *any* predecessor block's bit value is
/// `!BOTTOM_VALUE`.
///
/// There are situations where you want the opposite behaviour: propagate only if *all*
/// predecessor blocks's value is `!BOTTOM_VALUE`.
/// E.g. if you want to know whether a bit is *definitely* set at a specific location. This
/// means that all code paths leading to the location must have set the bit, instead of any
/// code path leading there.
///
/// If you want this kind of "definitely set" analysis, you need to
/// 1. Invert `BOTTOM_VALUE`
/// 2. Reset the `entry_set` in `start_block_effect` to `!BOTTOM_VALUE`
/// 3. Override `join` to do the opposite from what it's doing now.
#[inline]
fn join<T: Idx>(&self, inout_set: &mut BitSet<T>, in_set: &BitSet<T>) -> bool {
if Self::BOTTOM_VALUE == false {
Expand All @@ -685,7 +705,9 @@ pub trait BottomValue {
/// for each block individually. The entry set for all other basic blocks is
/// initialized to `Self::BOTTOM_VALUE`. The dataflow analysis then
/// iteratively modifies the various entry sets (but leaves the the transfer
/// function unchanged).
/// function unchanged). `BottomValue::join` is used to merge the bitsets from
/// two blocks (e.g. when two blocks' terminator jumps to a single block, that
/// target block's state is the merged state of both incoming blocks).
pub trait BitDenotation<'tcx>: BottomValue {
/// Specifies what index type is used to access the bitvector.
type Idx: Idx;
Expand Down
13 changes: 9 additions & 4 deletions src/librustc_parse/parser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub mod attr;
mod expr;
mod item;
mod module;
pub use module::{ModulePath, ModulePathSuccess};
mod pat;
mod path;
mod ty;
Expand Down Expand Up @@ -117,7 +118,8 @@ pub struct Parser<'a> {
/// Used to determine the path to externally loaded source files.
pub(super) directory: Directory<'a>,
/// `true` to parse sub-modules in other files.
pub(super) recurse_into_file_modules: bool,
// Public for rustfmt usage.
pub recurse_into_file_modules: bool,
/// Name of the root module this parser originated from. If `None`, then the
/// name is not known. This does not change while the parser is descending
/// into modules, and sub-parsers have new values for this name.
Expand All @@ -126,7 +128,8 @@ pub struct Parser<'a> {
token_cursor: TokenCursor,
desugar_doc_comments: bool,
/// `true` we should configure out of line modules as we parse.
cfg_mods: bool,
// Public for rustfmt usage.
pub cfg_mods: bool,
/// This field is used to keep track of how many left angle brackets we have seen. This is
/// required in order to detect extra leading left angle brackets (`<` characters) and error
/// appropriately.
Expand Down Expand Up @@ -483,7 +486,8 @@ impl<'a> Parser<'a> {
}
}

fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
// Public for rustfmt usage.
pub fn parse_ident(&mut self) -> PResult<'a, ast::Ident> {
self.parse_ident_common(true)
}

Expand Down Expand Up @@ -540,7 +544,8 @@ impl<'a> Parser<'a> {

/// If the next token is the given keyword, eats it and returns `true`.
/// Otherwise, returns `false`. An expectation is also added for diagnostics purposes.
fn eat_keyword(&mut self, kw: Symbol) -> bool {
// Public for rustfmt usage.
pub fn eat_keyword(&mut self, kw: Symbol) -> bool {
if self.check_keyword(kw) {
self.bump();
true
Expand Down
12 changes: 8 additions & 4 deletions src/librustc_parse/parser/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ use syntax::token::{self, TokenKind};
use std::path::{self, Path, PathBuf};

/// Information about the path to a module.
pub(super) struct ModulePath {
// Public for rustfmt usage.
pub struct ModulePath {
name: String,
path_exists: bool,
pub result: Result<ModulePathSuccess, Error>,
}

pub(super) struct ModulePathSuccess {
// Public for rustfmt usage.
pub struct ModulePathSuccess {
pub path: PathBuf,
pub directory_ownership: DirectoryOwnership,
}
Expand Down Expand Up @@ -177,7 +179,8 @@ impl<'a> Parser<'a> {
}
}

pub(super) fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> {
// Public for rustfmt usage.
pub fn submod_path_from_attr(attrs: &[Attribute], dir_path: &Path) -> Option<PathBuf> {
if let Some(s) = attr::first_attr_value_str_by_name(attrs, sym::path) {
let s = s.as_str();

Expand All @@ -194,7 +197,8 @@ impl<'a> Parser<'a> {
}

/// Returns a path to a module.
pub(super) fn default_submod_path(
// Public for rustfmt usage.
pub fn default_submod_path(
id: ast::Ident,
relative: Option<ast::Ident>,
dir_path: &Path,
Expand Down
8 changes: 4 additions & 4 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,11 @@ h4 > code, h3 > code, .invisible > code {
}

.content .stability::before {
content: '˪';
font-size: 30px;
content: '';
font-size: 25px;
position: absolute;
top: -9px;
left: -13px;
top: -6px;
left: -19px;
}

.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/themes/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ pre {
.content .highlighted.primitive { background-color: #00708a; }
.content .highlighted.keyword { background-color: #884719; }

.content .stability::before { color: #ccc; }

.content span.enum, .content a.enum, .block a.current.enum { color: #82b089; }
.content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; }
.content span.type, .content a.type, .block a.current.type { color: #ff7f00; }
Expand Down
2 changes: 2 additions & 0 deletions src/librustdoc/html/static/themes/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ pre {
.content .highlighted.primitive { background-color: #9aecff; }
.content .highlighted.keyword { background-color: #f99650; }

.content .stability::before { color: #ccc; }

.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
.content span.struct, .content a.struct, .block a.current.struct { color: #ad448e; }
.content span.type, .content a.type, .block a.current.type { color: #ba5d00; }
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub use core::time::Duration;
/// |:---------:|:--------------------------------------------------------------------:|
/// | Cloud ABI | [clock_time_get (Monotonic Clock)] |
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
/// | UNIX | [clock_time_get (Monotonic Clock)] |
/// | UNIX | [clock_gettime (Monotonic Clock)] |
/// | Darwin | [mach_absolute_time] |
/// | VXWorks | [clock_gettime (Monotonic Clock)] |
/// | WASI | [__wasi_clock_time_get (Monotonic Clock)] |
Expand Down
2 changes: 2 additions & 0 deletions src/libtest/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ fn optgroups() -> getopts::Options {
`RUST_TEST_TIME_DOCTEST` environment variables.
Expected format of environment variable is `VARIABLE=WARN_TIME,CRITICAL_TIME`.
Durations must be specified in milliseconds, e.g. `500,2000` means that the warn time
is 0.5 seconds, and the critical time is 2 seconds.
Not available for --format=terse",
"plain|colored",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// the change when it happens.
//
// At the time of authoring, the attributes here are listed in the
// order that they occur in libsyntax/feature_gate.rs.
// order that they occur in `librustc_feature`.
//
// Any builtin attributes that:
//
Expand Down

0 comments on commit af95804

Please sign in to comment.