Skip to content

Commit af95804

Browse files
committed
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
2 parents e82febc + 87bdc8e commit af95804

File tree

13 files changed

+73
-19
lines changed

13 files changed

+73
-19
lines changed

src/librustc_error_codes/error_codes/E0186.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ An associated function for a trait was defined to be a method (i.e., to take a
22
`self` parameter), but an implementation of the trait declared the same function
33
to be static.
44

5-
Here's an example of this error:
5+
Erroneous code example:
66

77
```compile_fail,E0186
88
trait Foo {
@@ -17,3 +17,19 @@ impl Foo for Bar {
1717
fn foo() {}
1818
}
1919
```
20+
21+
When a type implements a trait's associated function, it has to use the same
22+
signature. So in this case, since `Foo::foo` takes `self` as argument and
23+
does not return anything, its implementation on `Bar` should be the same:
24+
25+
```
26+
trait Foo {
27+
fn foo(&self);
28+
}
29+
30+
struct Bar;
31+
32+
impl Foo for Bar {
33+
fn foo(&self) {} // ok!
34+
}
35+
```

src/librustc_feature/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! # Feature gates
22
//!
33
//! This crate declares the set of past and present unstable features in the compiler.
4-
//! Feature gate checking itself is done in `libsyntax/feature_gate/check.rs` at the moment.
4+
//! Feature gate checking itself is done in `librustc_ast_passes/feature_gate.rs`
5+
//! at the moment.
56
//!
67
//! Features are enabled in programs via the crate-level attributes of
78
//! `#![feature(...)]` with a comma-separated list of features.

src/librustc_lint/builtin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1812,7 +1812,7 @@ declare_lint! {
18121812
}
18131813

18141814
declare_lint_pass!(
1815-
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `feature_gate.rs`.
1815+
/// Check for used feature gates in `INCOMPLETE_FEATURES` in `librustc_feature/active.rs`.
18161816
IncompleteFeatures => [INCOMPLETE_FEATURES]
18171817
);
18181818

src/librustc_lint/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ use unused::*;
7676

7777
/// Useful for other parts of the compiler / Clippy.
7878
pub use builtin::SoftLints;
79-
pub use context::{EarlyContext, LateContext, LintContext, LintStore};
79+
pub use context::{CheckLintNameResult, EarlyContext, LateContext, LintContext, LintStore};
8080
pub use early::check_ast_crate;
8181
pub use late::check_crate;
8282
pub use passes::{EarlyLintPass, LateLintPass};

src/librustc_mir/dataflow/mod.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,26 @@ pub trait BottomValue {
668668
const BOTTOM_VALUE: bool;
669669

670670
/// Merges `in_set` into `inout_set`, returning `true` if `inout_set` changed.
671+
///
672+
/// It is almost certainly wrong to override this, since it automatically applies
673+
/// * `inout_set & in_set` if `BOTTOM_VALUE == true`
674+
/// * `inout_set | in_set` if `BOTTOM_VALUE == false`
675+
///
676+
/// This means that if a bit is not `BOTTOM_VALUE`, it is propagated into all target blocks.
677+
/// For clarity, the above statement again from a different perspective:
678+
/// A bit in the block's entry set is `!BOTTOM_VALUE` if *any* predecessor block's bit value is
679+
/// `!BOTTOM_VALUE`.
680+
///
681+
/// There are situations where you want the opposite behaviour: propagate only if *all*
682+
/// predecessor blocks's value is `!BOTTOM_VALUE`.
683+
/// E.g. if you want to know whether a bit is *definitely* set at a specific location. This
684+
/// means that all code paths leading to the location must have set the bit, instead of any
685+
/// code path leading there.
686+
///
687+
/// If you want this kind of "definitely set" analysis, you need to
688+
/// 1. Invert `BOTTOM_VALUE`
689+
/// 2. Reset the `entry_set` in `start_block_effect` to `!BOTTOM_VALUE`
690+
/// 3. Override `join` to do the opposite from what it's doing now.
671691
#[inline]
672692
fn join<T: Idx>(&self, inout_set: &mut BitSet<T>, in_set: &BitSet<T>) -> bool {
673693
if Self::BOTTOM_VALUE == false {
@@ -685,7 +705,9 @@ pub trait BottomValue {
685705
/// for each block individually. The entry set for all other basic blocks is
686706
/// initialized to `Self::BOTTOM_VALUE`. The dataflow analysis then
687707
/// iteratively modifies the various entry sets (but leaves the the transfer
688-
/// function unchanged).
708+
/// function unchanged). `BottomValue::join` is used to merge the bitsets from
709+
/// two blocks (e.g. when two blocks' terminator jumps to a single block, that
710+
/// target block's state is the merged state of both incoming blocks).
689711
pub trait BitDenotation<'tcx>: BottomValue {
690712
/// Specifies what index type is used to access the bitvector.
691713
type Idx: Idx;

src/librustc_parse/parser/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ pub mod attr;
22
mod expr;
33
mod item;
44
mod module;
5+
pub use module::{ModulePath, ModulePathSuccess};
56
mod pat;
67
mod path;
78
mod ty;
@@ -117,7 +118,8 @@ pub struct Parser<'a> {
117118
/// Used to determine the path to externally loaded source files.
118119
pub(super) directory: Directory<'a>,
119120
/// `true` to parse sub-modules in other files.
120-
pub(super) recurse_into_file_modules: bool,
121+
// Public for rustfmt usage.
122+
pub recurse_into_file_modules: bool,
121123
/// Name of the root module this parser originated from. If `None`, then the
122124
/// name is not known. This does not change while the parser is descending
123125
/// into modules, and sub-parsers have new values for this name.
@@ -126,7 +128,8 @@ pub struct Parser<'a> {
126128
token_cursor: TokenCursor,
127129
desugar_doc_comments: bool,
128130
/// `true` we should configure out of line modules as we parse.
129-
cfg_mods: bool,
131+
// Public for rustfmt usage.
132+
pub cfg_mods: bool,
130133
/// This field is used to keep track of how many left angle brackets we have seen. This is
131134
/// required in order to detect extra leading left angle brackets (`<` characters) and error
132135
/// appropriately.
@@ -483,7 +486,8 @@ impl<'a> Parser<'a> {
483486
}
484487
}
485488

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

@@ -540,7 +544,8 @@ impl<'a> Parser<'a> {
540544

541545
/// If the next token is the given keyword, eats it and returns `true`.
542546
/// Otherwise, returns `false`. An expectation is also added for diagnostics purposes.
543-
fn eat_keyword(&mut self, kw: Symbol) -> bool {
547+
// Public for rustfmt usage.
548+
pub fn eat_keyword(&mut self, kw: Symbol) -> bool {
544549
if self.check_keyword(kw) {
545550
self.bump();
546551
true

src/librustc_parse/parser/module.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ use syntax::token::{self, TokenKind};
1414
use std::path::{self, Path, PathBuf};
1515

1616
/// Information about the path to a module.
17-
pub(super) struct ModulePath {
17+
// Public for rustfmt usage.
18+
pub struct ModulePath {
1819
name: String,
1920
path_exists: bool,
2021
pub result: Result<ModulePathSuccess, Error>,
2122
}
2223

23-
pub(super) struct ModulePathSuccess {
24+
// Public for rustfmt usage.
25+
pub struct ModulePathSuccess {
2426
pub path: PathBuf,
2527
pub directory_ownership: DirectoryOwnership,
2628
}
@@ -177,7 +179,8 @@ impl<'a> Parser<'a> {
177179
}
178180
}
179181

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

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

196199
/// Returns a path to a module.
197-
pub(super) fn default_submod_path(
200+
// Public for rustfmt usage.
201+
pub fn default_submod_path(
198202
id: ast::Ident,
199203
relative: Option<ast::Ident>,
200204
dir_path: &Path,

src/librustdoc/html/static/rustdoc.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -542,11 +542,11 @@ h4 > code, h3 > code, .invisible > code {
542542
}
543543

544544
.content .stability::before {
545-
content: '˪';
546-
font-size: 30px;
545+
content: '';
546+
font-size: 25px;
547547
position: absolute;
548-
top: -9px;
549-
left: -13px;
548+
top: -6px;
549+
left: -19px;
550550
}
551551

552552
.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant {

src/librustdoc/html/static/themes/dark.css

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ pre {
105105
.content .highlighted.primitive { background-color: #00708a; }
106106
.content .highlighted.keyword { background-color: #884719; }
107107

108+
.content .stability::before { color: #ccc; }
109+
108110
.content span.enum, .content a.enum, .block a.current.enum { color: #82b089; }
109111
.content span.struct, .content a.struct, .block a.current.struct { color: #2dbfb8; }
110112
.content span.type, .content a.type, .block a.current.type { color: #ff7f00; }

src/librustdoc/html/static/themes/light.css

+2
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ pre {
105105
.content .highlighted.primitive { background-color: #9aecff; }
106106
.content .highlighted.keyword { background-color: #f99650; }
107107

108+
.content .stability::before { color: #ccc; }
109+
108110
.content span.enum, .content a.enum, .block a.current.enum { color: #508157; }
109111
.content span.struct, .content a.struct, .block a.current.struct { color: #ad448e; }
110112
.content span.type, .content a.type, .block a.current.type { color: #ba5d00; }

src/libstd/time.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub use core::time::Duration;
6767
/// |:---------:|:--------------------------------------------------------------------:|
6868
/// | Cloud ABI | [clock_time_get (Monotonic Clock)] |
6969
/// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] |
70-
/// | UNIX | [clock_time_get (Monotonic Clock)] |
70+
/// | UNIX | [clock_gettime (Monotonic Clock)] |
7171
/// | Darwin | [mach_absolute_time] |
7272
/// | VXWorks | [clock_gettime (Monotonic Clock)] |
7373
/// | WASI | [__wasi_clock_time_get (Monotonic Clock)] |

src/libtest/cli.rs

+2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ fn optgroups() -> getopts::Options {
125125
`RUST_TEST_TIME_DOCTEST` environment variables.
126126
127127
Expected format of environment variable is `VARIABLE=WARN_TIME,CRITICAL_TIME`.
128+
Durations must be specified in milliseconds, e.g. `500,2000` means that the warn time
129+
is 0.5 seconds, and the critical time is 2 seconds.
128130
129131
Not available for --format=terse",
130132
"plain|colored",

src/test/ui/feature-gate/issue-43106-gating-of-builtin-attrs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// the change when it happens.
1313
//
1414
// At the time of authoring, the attributes here are listed in the
15-
// order that they occur in libsyntax/feature_gate.rs.
15+
// order that they occur in `librustc_feature`.
1616
//
1717
// Any builtin attributes that:
1818
//

0 commit comments

Comments
 (0)