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 12 pull requests #60510

Merged
merged 44 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bee92b5
Make deprecation lint `ambiguous_associated_items` deny-by-default
petrochenkov Apr 12, 2019
a912664
report fatal errors during doctest parsing
euclio Apr 23, 2019
0e7e938
Do not suggest incorrect syntax on pattern borrow error
estebank Apr 30, 2019
742b48d
Be more specific in the suggestion filtering
estebank Apr 30, 2019
ff68673
add tests
estebank Apr 30, 2019
693eea5
review comments
estebank Apr 30, 2019
14ca950
Fix style
estebank Apr 30, 2019
6068478
Add if let test
estebank Apr 30, 2019
bf4d0ad
Rename to RUSTC_LOG
JohnTitor Apr 30, 2019
da46eea
Add error for existential types
JohnTitor Apr 30, 2019
bb3549f
Fix tests
JohnTitor Apr 30, 2019
f56d285
Use multispan
JohnTitor Apr 30, 2019
db7f265
Fix spans
JohnTitor Apr 30, 2019
748d978
Fix run-pass test
JohnTitor Apr 30, 2019
ed08c6a
review comments: change wording
estebank Apr 30, 2019
24fddb1
Resolve match arm ty when arms diverge
estebank May 1, 2019
c6e13bc
Disallow non-explicit elided lifetimes in async fn
cramertj Apr 30, 2019
6ef39e6
Avoid repeated interning of static strings.
nnethercote May 2, 2019
16fe8cc
Remove the `self.mir` field from `ConstPropagator`
wesleywiser Apr 29, 2019
cac07eb
Fix failing test
wesleywiser May 2, 2019
8b82f68
Make find_attr_val a little bit more precise
rasendubi Apr 29, 2019
b7f55ca
Assign group and parse since for Feature
rasendubi Apr 29, 2019
d5ba6d4
Ensure language features in group are sorted by since
rasendubi Apr 29, 2019
d54477e
Address review comments
rasendubi May 1, 2019
90d3fa2
Make tidy::version::Version a [u32; 3]
rasendubi May 1, 2019
3b4fe7e
Group and sort feature_gate.rs
rasendubi May 1, 2019
c120fd8
Rework Version::parse to avoid extra allocations
rasendubi May 1, 2019
4bcc828
Make in_feature_group a simple bool flag
rasendubi May 2, 2019
201f14b
Make tidy::version::Version copy
rasendubi May 2, 2019
69fd757
fix markdown syntax in `LateContext` examples
euclio May 2, 2019
bbe7b85
mention `hir::Body` in docs for `hir::FnDecl`
euclio May 2, 2019
2fe50bc
Propagate mutability from arguments to local bindings in async fn
taiki-e May 3, 2019
e9509f8
Rollup merge of #59928 - petrochenkov:denyambass, r=varkor
Centril May 3, 2019
06e1d88
Rollup merge of #60220 - euclio:rustdoc-test-fatal-parsing-errors, r=…
Centril May 3, 2019
9199bb5
Rollup merge of #60373 - rasendubi:lang-features-sort-since, r=Centril
Centril May 3, 2019
3ca0d36
Rollup merge of #60388 - cramertj:elided-lifetime-async, r=nikomatsakis
Centril May 3, 2019
3e536e8
Rollup merge of #60393 - estebank:pat-sugg, r=oli-obk
Centril May 3, 2019
bfa22cf
Rollup merge of #60401 - JohnTitor:rename-log, r=davidtwco
Centril May 3, 2019
f622861
Rollup merge of #60409 - JohnTitor:error-for-existential-type, r=oli-obk
Centril May 3, 2019
2b5e296
Rollup merge of #60455 - estebank:resolve-match-arm-ty, r=davidtwco
Centril May 3, 2019
3fe5fac
Rollup merge of #60457 - wesleywiser:const_prop_refactoring, r=oli-obk
Centril May 3, 2019
0784755
Rollup merge of #60467 - nnethercote:less-symbol-interning, r=davidtwco
Centril May 3, 2019
d5809a8
Rollup merge of #60478 - euclio:doc-fixes, r=cramertj
Centril May 3, 2019
6f7a1ea
Rollup merge of #60501 - taiki-e:async-await-mutable-arguments, r=cra…
Centril May 3, 2019
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3556,6 +3556,7 @@ dependencies = [
name = "tidy"
version = "0.1.0"
dependencies = [
"regex 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"serde 1.0.82 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_derive 1.0.81 (registry+https://github.com/rust-lang/crates.io-index)",
"serde_json 1.0.33 (registry+https://github.com/rust-lang/crates.io-index)",
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ fn configure_cmake(builder: &Builder<'_>,
}

if env::var_os("SCCACHE_ERROR_LOG").is_some() {
cfg.env("RUST_LOG", "sccache=warn");
cfg.env("RUSTC_LOG", "sccache=warn");
}
}

Expand Down
5 changes: 1 addition & 4 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,6 @@ struct Foo1 { x: &bool }
// ^ expected lifetime parameter
struct Foo2<'a> { x: &'a bool } // correct

impl Foo2 {}
// ^^^^ expected lifetime parameter
impl<'a> Foo2<'a> {} // correct

struct Bar1 { x: Foo2 }
// ^^^^ expected lifetime parameter
struct Bar2<'a> { x: Foo2<'a> } // correct
Expand Down Expand Up @@ -2208,4 +2204,5 @@ register_diagnostics! {
E0710, // an unknown tool name found in scoped lint
E0711, // a feature has been declared with conflicting stability attributes
// E0702, // replaced with a generic attribute input check
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
}
68 changes: 52 additions & 16 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,15 +2110,49 @@ impl<'a> LoweringContext<'a> {
.expect("already checked that type args or bindings exist");
(false, first_generic_span.shrink_to_lo(), format!("{}, ", anon_lt_suggestion))
};
self.sess.buffer_lint_with_diagnostic(
ELIDED_LIFETIMES_IN_PATHS,
CRATE_NODE_ID,
path_span,
"hidden lifetime parameters in types are deprecated",
builtin::BuiltinLintDiagnostics::ElidedLifetimesInPaths(
expected_lifetimes, path_span, incl_angl_brckt, insertion_span, suggestion
)
);
match self.anonymous_lifetime_mode {
// In create-parameter mode we error here because we don't want to support
// deprecated impl elision in new features like impl elision and `async fn`,
// both of which work using the `CreateParameter` mode:
//
// impl Foo for std::cell::Ref<u32> // note lack of '_
// async fn foo(_: std::cell::Ref<u32>) { ... }
AnonymousLifetimeMode::CreateParameter => {
let mut err = struct_span_err!(
self.sess,
path_span,
E0726,
"implicit elided lifetime not allowed here"
);
crate::lint::builtin::add_elided_lifetime_in_path_suggestion(
&self.sess,
&mut err,
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
suggestion,
);
err.emit();
}
AnonymousLifetimeMode::PassThrough |
AnonymousLifetimeMode::ReportError |
AnonymousLifetimeMode::Replace(_) => {
self.sess.buffer_lint_with_diagnostic(
ELIDED_LIFETIMES_IN_PATHS,
CRATE_NODE_ID,
path_span,
"hidden lifetime parameters in types are deprecated",
builtin::BuiltinLintDiagnostics::ElidedLifetimesInPaths(
expected_lifetimes,
path_span,
incl_angl_brckt,
insertion_span,
suggestion,
)
);
}
}
}
}

Expand Down Expand Up @@ -5335,13 +5369,15 @@ impl<'a> LoweringContext<'a> {

fn elided_path_lifetime(&mut self, span: Span) -> hir::Lifetime {
match self.anonymous_lifetime_mode {
// N.B., We intentionally ignore the create-parameter mode here
// and instead "pass through" to resolve-lifetimes, which will then
// report an error. This is because we don't want to support
// impl elision for deprecated forms like
//
// impl Foo for std::cell::Ref<u32> // note lack of '_
AnonymousLifetimeMode::CreateParameter |
AnonymousLifetimeMode::CreateParameter => {
// We should have emitted E0726 when processing this path above
self.sess.delay_span_bug(
span,
"expected 'implicit elided lifetime not allowed' error",
);
let id = self.sess.next_node_id();
self.new_named_lifetime(id, span, hir::LifetimeName::Error)
}
// This is the normal case.
AnonymousLifetimeMode::PassThrough => self.new_implicit_lifetime(span),

Expand Down
3 changes: 3 additions & 0 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1927,6 +1927,9 @@ pub enum ArgSource {
/// Represents the header (not the body) of a function declaration.
#[derive(Clone, RustcEncodable, RustcDecodable, Debug, HashStable)]
pub struct FnDecl {
/// The types of the function's arguments.
///
/// Additional argument data is stored in the function's [body](Body::arguments).
pub inputs: HirVec<Ty>,
pub output: FunctionRetTy,
pub c_variadic: bool,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/error_reporting/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
for sp in prior_arms {
err.span_label(*sp, format!(
"this is found to be of type `{}`",
last_ty,
self.resolve_type_vars_if_possible(&last_ty),
));
}
} else if let Some(sp) = prior_arms.last() {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
/// potentially leaving "dangling type variables" behind.
/// In such cases, an assertion will fail when attempting to
/// register obligations, within a snapshot. Very useful, much
/// better than grovelling through megabytes of `RUST_LOG` output.
/// better than grovelling through megabytes of `RUSTC_LOG` output.
///
/// HOWEVER, in some cases the flag is unhelpful. In particular, we
/// sometimes create a "mini-fulfilment-cx" in which we enroll
Expand Down
82 changes: 51 additions & 31 deletions src/librustc/lint/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ declare_lint! {

declare_lint! {
pub AMBIGUOUS_ASSOCIATED_ITEMS,
Warn,
Deny,
"ambiguous associated items"
}

Expand Down Expand Up @@ -477,6 +477,48 @@ pub enum BuiltinLintDiagnostics {
RedundantImport(Vec<(Span, bool)>, ast::Ident),
}

pub(crate) fn add_elided_lifetime_in_path_suggestion(
sess: &Session,
db: &mut DiagnosticBuilder<'_>,
n: usize,
path_span: Span,
incl_angl_brckt: bool,
insertion_span: Span,
anon_lts: String,
) {
let (replace_span, suggestion) = if incl_angl_brckt {
(insertion_span, anon_lts)
} else {
// When possible, prefer a suggestion that replaces the whole
// `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, `
// at a point (which makes for an ugly/confusing label)
if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) {
// But our spans can get out of whack due to macros; if the place we think
// we want to insert `'_` isn't even within the path expression's span, we
// should bail out of making any suggestion rather than panicking on a
// subtract-with-overflow or string-slice-out-out-bounds (!)
// FIXME: can we do better?
if insertion_span.lo().0 < path_span.lo().0 {
return;
}
let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize;
if insertion_index > snippet.len() {
return;
}
let (before, after) = snippet.split_at(insertion_index);
(path_span, format!("{}{}{}", before, anon_lts, after))
} else {
(insertion_span, anon_lts)
}
};
db.span_suggestion(
replace_span,
&format!("indicate the anonymous lifetime{}", if n >= 2 { "s" } else { "" }),
suggestion,
Applicability::MachineApplicable
);
}

impl BuiltinLintDiagnostics {
pub fn run(self, sess: &Session, db: &mut DiagnosticBuilder<'_>) {
match self {
Expand Down Expand Up @@ -521,36 +563,14 @@ impl BuiltinLintDiagnostics {
BuiltinLintDiagnostics::ElidedLifetimesInPaths(
n, path_span, incl_angl_brckt, insertion_span, anon_lts
) => {
let (replace_span, suggestion) = if incl_angl_brckt {
(insertion_span, anon_lts)
} else {
// When possible, prefer a suggestion that replaces the whole
// `Path<T>` expression with `Path<'_, T>`, rather than inserting `'_, `
// at a point (which makes for an ugly/confusing label)
if let Ok(snippet) = sess.source_map().span_to_snippet(path_span) {
// But our spans can get out of whack due to macros; if the place we think
// we want to insert `'_` isn't even within the path expression's span, we
// should bail out of making any suggestion rather than panicking on a
// subtract-with-overflow or string-slice-out-out-bounds (!)
// FIXME: can we do better?
if insertion_span.lo().0 < path_span.lo().0 {
return;
}
let insertion_index = (insertion_span.lo().0 - path_span.lo().0) as usize;
if insertion_index > snippet.len() {
return;
}
let (before, after) = snippet.split_at(insertion_index);
(path_span, format!("{}{}{}", before, anon_lts, after))
} else {
(insertion_span, anon_lts)
}
};
db.span_suggestion(
replace_span,
&format!("indicate the anonymous lifetime{}", if n >= 2 { "s" } else { "" }),
suggestion,
Applicability::MachineApplicable
add_elided_lifetime_in_path_suggestion(
sess,
db,
n,
path_span,
incl_angl_brckt,
insertion_span,
anon_lts,
);
}
BuiltinLintDiagnostics::UnknownCrateTypes(span, note, sugg) => {
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/lint/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,12 +757,12 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
/// Check if a `DefId`'s path matches the given absolute type path usage.
///
/// # Examples
/// ```rust,ignore (no `cx` or `def_id` available)
///
/// ```rust,ignore (no context or def id available)
/// if cx.match_def_path(def_id, &["core", "option", "Option"]) {
/// // The given `def_id` is that of an `Option` type
/// }
/// ```
// Uplifted from rust-lang/rust-clippy
pub fn match_def_path(&self, def_id: DefId, path: &[&str]) -> bool {
let names = self.get_def_path(def_id);

Expand All @@ -772,13 +772,13 @@ impl<'a, 'tcx> LateContext<'a, 'tcx> {
/// Gets the absolute path of `def_id` as a vector of `&str`.
///
/// # Examples
/// ```rust,ignore (no `cx` or `def_id` available)
///
/// ```rust,ignore (no context or def id available)
/// let def_path = cx.get_def_path(def_id);
/// if let &["core", "option", "Option"] = &def_path[..] {
/// // The given `def_id` is that of an `Option` type
/// }
/// ```
// Uplifted from rust-lang/rust-clippy
pub fn get_def_path(&self, def_id: DefId) -> Vec<LocalInternedString> {
pub struct AbsolutePathPrinter<'a, 'tcx> {
pub tcx: TyCtxt<'a, 'tcx, 'tcx>,
Expand Down
22 changes: 13 additions & 9 deletions src/librustc_codegen_llvm/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,26 +784,30 @@ pub fn file_metadata(cx: &CodegenCx<'ll, '_>,
file_name,
defining_crate);

let directory = if defining_crate == LOCAL_CRATE {
&cx.sess().working_dir.0
let file_name = &file_name.to_string();
let file_name_symbol = Symbol::intern(file_name);
if defining_crate == LOCAL_CRATE {
let directory = &cx.sess().working_dir.0.to_string_lossy();
file_metadata_raw(cx, file_name, Some(file_name_symbol),
directory, Some(Symbol::intern(directory)))
} else {
// If the path comes from an upstream crate we assume it has been made
// independent of the compiler's working directory one way or another.
Path::new("")
};

file_metadata_raw(cx, &file_name.to_string(), &directory.to_string_lossy())
file_metadata_raw(cx, file_name, Some(file_name_symbol), "", None)
}
}

pub fn unknown_file_metadata(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
file_metadata_raw(cx, "<unknown>", "")
file_metadata_raw(cx, "<unknown>", None, "", None)
}

fn file_metadata_raw(cx: &CodegenCx<'ll, '_>,
file_name: &str,
directory: &str)
file_name_symbol: Option<Symbol>,
directory: &str,
directory_symbol: Option<Symbol>)
-> &'ll DIFile {
let key = (Symbol::intern(file_name), Symbol::intern(directory));
let key = (file_name_symbol, directory_symbol);

if let Some(file_metadata) = debug_context(cx).created_files.borrow().get(&key) {
return *file_metadata;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pub struct CrateDebugContext<'a, 'tcx> {
llcontext: &'a llvm::Context,
llmod: &'a llvm::Module,
builder: &'a mut DIBuilder<'a>,
created_files: RefCell<FxHashMap<(Symbol, Symbol), &'a DIFile>>,
created_files: RefCell<FxHashMap<(Option<Symbol>, Option<Symbol>), &'a DIFile>>,
created_enum_disr_types: RefCell<FxHashMap<(DefId, layout::Primitive), &'a DIType>>,

type_map: RefCell<TypeMap<'a, 'tcx>>,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ pub fn report_ices_to_stderr_if_any<F: FnOnce() -> R, R>(f: F) -> Result<R, Erro
/// This allows tools to enable rust logging without having to magically match rustc's
/// log crate version
pub fn init_rustc_env_logger() {
env_logger::init();
env_logger::init_from_env("RUSTC_LOG");
}

pub fn main() {
Expand Down
Loading