Auto merge of #68174 - JohnTitor:rollup-ix4amrj, r=JohnTitor
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
diff --git a/src/librustc_error_codes/error_codes/E0186.md b/src/librustc_error_codes/error_codes/E0186.md
index 9135d5c..7db1e84 100644
--- a/src/librustc_error_codes/error_codes/E0186.md
+++ b/src/librustc_error_codes/error_codes/E0186.md
@@ -2,7 +2,7 @@
`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 {
@@ -17,3 +17,19 @@
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!
+}
+```
diff --git a/src/librustc_feature/lib.rs b/src/librustc_feature/lib.rs
index 71a4642..01546f7 100644
--- a/src/librustc_feature/lib.rs
+++ b/src/librustc_feature/lib.rs
@@ -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.
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 15a8332..6aa809a 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -1812,7 +1812,7 @@
}
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]
);
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index 6e3382d..78e9d0f 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -76,7 +76,7 @@
/// 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};
diff --git a/src/librustc_mir/dataflow/mod.rs b/src/librustc_mir/dataflow/mod.rs
index 01f6177..e29730f 100644
--- a/src/librustc_mir/dataflow/mod.rs
+++ b/src/librustc_mir/dataflow/mod.rs
@@ -668,6 +668,26 @@
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 {
@@ -685,7 +705,9 @@
/// 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;
diff --git a/src/librustc_parse/parser/mod.rs b/src/librustc_parse/parser/mod.rs
index a1035d3..1368230 100644
--- a/src/librustc_parse/parser/mod.rs
+++ b/src/librustc_parse/parser/mod.rs
@@ -2,6 +2,7 @@
mod expr;
mod item;
mod module;
+pub use module::{ModulePath, ModulePathSuccess};
mod pat;
mod path;
mod ty;
@@ -117,7 +118,8 @@
/// 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.
@@ -126,7 +128,8 @@
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.
@@ -483,7 +486,8 @@
}
}
- 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)
}
@@ -540,7 +544,8 @@
/// 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
diff --git a/src/librustc_parse/parser/module.rs b/src/librustc_parse/parser/module.rs
index 3254ab5..6ce94d3 100644
--- a/src/librustc_parse/parser/module.rs
+++ b/src/librustc_parse/parser/module.rs
@@ -14,13 +14,15 @@
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,
}
@@ -177,7 +179,8 @@
}
}
- 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();
@@ -194,7 +197,8 @@
}
/// 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,
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 62fe230..a91fdb7 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -542,11 +542,11 @@
}
.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 {
diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css
index f46bd6d..9a0e7bb 100644
--- a/src/librustdoc/html/static/themes/dark.css
+++ b/src/librustdoc/html/static/themes/dark.css
@@ -105,6 +105,8 @@
.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; }
diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css
index ca67b1c..ca8ea1c 100644
--- a/src/librustdoc/html/static/themes/light.css
+++ b/src/librustdoc/html/static/themes/light.css
@@ -105,6 +105,8 @@
.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; }
diff --git a/src/libstd/time.rs b/src/libstd/time.rs
index 0dce8f8..0b6e728 100644
--- a/src/libstd/time.rs
+++ b/src/libstd/time.rs
@@ -67,7 +67,7 @@
/// |:---------:|:--------------------------------------------------------------------:|
/// | 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)] |
diff --git a/src/libtest/cli.rs b/src/libtest/cli.rs
index ea6d632..edff8be 100644
--- a/src/libtest/cli.rs
+++ b/src/libtest/cli.rs
@@ -125,6 +125,8 @@
`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",
diff --git a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs
index 0d804f0..92c5c20 100644
--- a/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs
+++ b/src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs
@@ -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:
//