Skip to content
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

Rollup of 7 pull requests #68158

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9158e17
Document more use cases of dataflow
oli-obk Dec 15, 2019
5f08df1
Address review comments
oli-obk Dec 20, 2019
1ffb9cf
rustdoc: improve stability mark arrows
liigo Jan 7, 2020
ae3a53f
rustdoc: use another stability mark arrow, no rotate.
liigo Jan 9, 2020
91e9531
Clarify test timeout evironment variables
MikailBag Jan 10, 2020
ed039e8
restore some rustc_parse visibilities
calebcartwright Jan 11, 2020
a404cfa
Expose `context::CheckLintNameResult`
JohnTitor Jan 12, 2020
0810210
Diagnostics should start lowercase
varkor Jan 10, 2020
8461fa5
Diagnostics should not end with a full stop
varkor Jan 10, 2020
e842489
Add backticks in appropriate places
varkor Jan 10, 2020
3de9b8a
Fix formatting ellipses at the end of some diagnostics
varkor Jan 10, 2020
117443e
Appease tidy
varkor Jan 10, 2020
1faa05d
Update `output-default.json` and rustdoc test
varkor Jan 10, 2020
34186ef
Clean up E0186 explanation
GuillaumeGomez Jan 12, 2020
4fc2765
Rollup merge of #67313 - oli-obk:document_all_the_t̶h̶i̶n̶g̶s̶dataflo…
Dylan-DPC Jan 12, 2020
b33b791
Rollup merge of #67959 - liigo:patch-13, r=GuillaumeGomez
Dylan-DPC Jan 12, 2020
3794082
Rollup merge of #68096 - varkor:diagnostic-cleanup, r=Centril
Dylan-DPC Jan 12, 2020
686f9ad
Rollup merge of #68097 - MikailBag:master, r=shepmaster
Dylan-DPC Jan 12, 2020
e7e8435
Rollup merge of #68135 - calebcartwright:rustc-parse-visibilities, r=…
Dylan-DPC Jan 12, 2020
9b28218
Rollup merge of #68145 - JohnTitor:pub-check-lint-name-result, r=Centril
Dylan-DPC Jan 12, 2020
30d7419
Rollup merge of #68157 - GuillaumeGomez:clean-up-e0186, r=Dylan-DPC
Dylan-DPC Jan 12, 2020
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
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// Here we explicitly #[cfg]-out this whole crate when testing. If we don't do
// this, both the generated test artifact and the linked libtest (which
// transitively includes libcore) will both define the same set of lang items,
// and this will cause the E0152 "duplicate lang item found" error. See
// and this will cause the E0152 "found duplicate lang item" error. See
// discussion in #50466 for details.
//
// This cfg won't affect doc tests.
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl LanguageItemCollector<'tcx> {
self.tcx.sess,
span,
E0152,
"duplicate lang item found: `{}`.",
"found duplicate lang item `{}`",
name
),
None => {
Expand All @@ -206,12 +206,12 @@ impl LanguageItemCollector<'tcx> {
},
};
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
err.span_note(span, "first defined here.");
err.span_note(span, "first defined here");
} else {
match self.tcx.extern_crate(original_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
err.note(&format!(
"first defined in crate `{}` (which `{}` depends on).",
"first defined in crate `{}` (which `{}` depends on)",
self.tcx.crate_name(original_def_id.krate),
self.tcx.crate_name(*dependency_of)));
},
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
err.span_help(impl_span, "trait impl with same name found");
let trait_crate = self.tcx.crate_name(trait_with_same_path.krate);
let crate_msg = format!(
"Perhaps two different versions of crate `{}` are being used?",
"perhaps two different versions of crate `{}` are being used?",
trait_crate
);
err.note(&crate_msg);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_ast_passes/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
self.check_extern(bare_fn_ty.ext);
}
ast::TyKind::Never => {
gate_feature_post!(&self, never_type, ty.span, "The `!` type is experimental");
gate_feature_post!(&self, never_type, ty.span, "the `!` type is experimental");
}
_ => {}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_builtin_macros/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic {
`expected = \"error message\"`",
)
.note(
"Errors in this attribute were erroneously \
"errors in this attribute were erroneously \
allowed and will become a hard error in a \
future release.",
)
Expand Down
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!
}
```
23 changes: 13 additions & 10 deletions src/librustc_lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ impl EarlyLintPass for AnonymousParameters {
)
.span_suggestion(
arg.pat.span,
"Try naming the parameter or explicitly \
"try naming the parameter or explicitly \
ignoring it",
format!("_: {}", ty_snip),
appl,
Expand Down Expand Up @@ -1934,21 +1934,21 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
use rustc::ty::TyKind::*;
match ty.kind {
// Primitive types that don't like 0 as a value.
Ref(..) => Some((format!("References must be non-null"), None)),
Ref(..) => Some((format!("references must be non-null"), None)),
Adt(..) if ty.is_box() => Some((format!("`Box` must be non-null"), None)),
FnPtr(..) => Some((format!("Function pointers must be non-null"), None)),
Never => Some((format!("The never type (`!`) has no valid value"), None)),
FnPtr(..) => Some((format!("function pointers must be non-null"), None)),
Never => Some((format!("the `!` type has no valid value"), None)),
RawPtr(tm) if matches!(tm.ty.kind, Dynamic(..)) =>
// raw ptr to dyn Trait
{
Some((format!("The vtable of a wide raw pointer must be non-null"), None))
Some((format!("the vtable of a wide raw pointer must be non-null"), None))
}
// Primitive types with other constraints.
Bool if init == InitKind::Uninit => {
Some((format!("Booleans must be `true` or `false`"), None))
Some((format!("booleans must be either `true` or `false`"), None))
}
Char if init == InitKind::Uninit => {
Some((format!("Characters must be a valid unicode codepoint"), None))
Some((format!("characters must be a valid Unicode codepoint"), None))
}
// Recurse and checks for some compound types.
Adt(adt_def, substs) if !adt_def.is_union() => {
Expand All @@ -1959,21 +1959,24 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for InvalidValue {
// return `Bound::Excluded`. (And we have tests checking that we
// handle the attribute correctly.)
(Bound::Included(lo), _) if lo > 0 => {
return Some((format!("{} must be non-null", ty), None));
return Some((format!("`{}` must be non-null", ty), None));
}
(Bound::Included(_), _) | (_, Bound::Included(_))
if init == InitKind::Uninit =>
{
return Some((
format!("{} must be initialized inside its custom valid range", ty),
format!(
"`{}` must be initialized inside its custom valid range",
ty,
),
None,
));
}
_ => {}
}
// Now, recurse.
match adt_def.variants.len() {
0 => Some((format!("0-variant enums have no valid value"), None)),
0 => Some((format!("enums with no variants have no valid value"), None)),
1 => {
// Struct, or enum with exactly one variant.
// Proceed recursively, check all fields.
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
4 changes: 2 additions & 2 deletions src/librustc_mir/borrow_check/nll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(
// better.

if let Some(closure_region_requirements) = closure_region_requirements {
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "External requirements");
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "external requirements");

regioncx.annotate(tcx, &mut err);

Expand All @@ -379,7 +379,7 @@ pub(super) fn dump_annotation<'a, 'tcx>(

err.buffer(errors_buffer);
} else {
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "No external requirements");
let mut err = tcx.sess.diagnostic().span_note_diag(body.span, "no external requirements");
regioncx.annotate(tcx, &mut err);

err.buffer(errors_buffer);
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
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ impl<'a> Parser<'a> {
self.struct_span_err(lit.span, msg)
.help(
"instead of using a suffixed literal \
(1u8, 1.0f32, etc.), use an unsuffixed version \
(1, 1.0, etc.).",
(`1u8`, `1.0f32`, etc.), use an unsuffixed version \
(`1`, `1.0`, etc.)",
)
.emit()
}
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
4 changes: 2 additions & 2 deletions src/librustc_parse/parser/pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ impl<'a> Parser<'a> {
if let Ok(seq_snippet) = self.span_to_snippet(seq_span) {
err.span_suggestion(
seq_span,
"try adding parentheses to match on a tuple..",
"try adding parentheses to match on a tuple...",
format!("({})", seq_snippet),
Applicability::MachineApplicable,
)
.span_suggestion(
seq_span,
"..or a vertical bar to match on multiple alternatives",
"...or a vertical bar to match on multiple alternatives",
format!("{}", seq_snippet.replace(",", " |")),
Applicability::MachineApplicable,
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_passes/diagnostic_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn collect_item(
)),
};
if let Some(span) = tcx.hir().span_if_local(original_def_id) {
err.span_note(span, "first defined here.");
err.span_note(span, "first defined here");
} else {
err.note(&format!(
"first defined in crate `{}`.",
Expand Down
8 changes: 4 additions & 4 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
.session
.struct_span_err(
attr.span,
"`macro_use` is not supported on `extern crate self`",
"`#[macro_use]` is not supported on `extern crate self`",
)
.emit();
}
Expand Down Expand Up @@ -1054,10 +1054,10 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
fn contains_macro_use(&mut self, attrs: &[ast::Attribute]) -> bool {
for attr in attrs {
if attr.check_name(sym::macro_escape) {
let msg = "macro_escape is a deprecated synonym for macro_use";
let msg = "`#[macro_escape]` is a deprecated synonym for `#[macro_use]`";
let mut err = self.r.session.struct_span_warn(attr.span, msg);
if let ast::AttrStyle::Inner = attr.style {
err.help("consider an outer attribute, `#[macro_use]` mod ...").emit();
err.help("try an outer attribute: `#[macro_use]`").emit();
} else {
err.emit();
}
Expand All @@ -1066,7 +1066,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
}

if !attr.is_word() {
self.r.session.span_err(attr.span, "arguments to macro_use are not allowed here");
self.r.session.span_err(attr.span, "arguments to `macro_use` are not allowed here");
}
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,7 @@ impl<'a> Resolver<'a> {
continue;
}
}
let msg = "there are too many initial `super`s.".to_string();
let msg = "there are too many leading `super` keywords".to_string();
return PathResult::Failed {
span: ident.span,
label: msg,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ impl<'a, 'tcx> CastCheck<'tcx> {
if unknown_cast_to { "to" } else { "from" }
);
err.note(
"The type information given here is insufficient to check whether \
"the type information given here is insufficient to check whether \
the pointer cast is valid",
);
if unknown_cast_to {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
macro_rules! report_function {
($span:expr, $name:expr) => {
err.note(&format!(
"{} is a function, perhaps you wish to call it",
"`{}` is a function, perhaps you wish to call it",
$name
));
};
Expand Down
Loading