Skip to content

Commit

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

Successful merges:

 - #64404 (Add long error explanation for E0495)
 - #64918 (Add long error explanation for E0551)
 - #65102 (Disable stack probe when thread sanitizer is enabled)
 - #65120 (Correctly estimate the required space for string in `StyledBuffer::prepend`)
 - #65145 (When suggesting assoc function with type params, include turbofish)
 - #65162 (Remove loaded_from_cache map from DepGraph)
 - #65176 (Remove query-related macros)
 - #65179 (Add long error explanation for E0567)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Oct 8, 2019
2 parents 3fa9554 + 3246ab2 commit 2748a9f
Showing 60 changed files with 266 additions and 91 deletions.
23 changes: 0 additions & 23 deletions src/librustc/dep_graph/graph.rs
Original file line number Diff line number Diff line change
@@ -75,9 +75,6 @@ struct DepGraphData {
previous_work_products: FxHashMap<WorkProductId, WorkProduct>,

dep_node_debug: Lock<FxHashMap<DepNode, String>>,

// Used for testing, only populated when -Zquery-dep-graph is specified.
loaded_from_cache: Lock<FxHashMap<DepNodeIndex, bool>>,
}

pub fn hash_result<R>(hcx: &mut StableHashingContext<'_>, result: &R) -> Option<Fingerprint>
@@ -104,7 +101,6 @@ impl DepGraph {
emitting_diagnostics_cond_var: Condvar::new(),
previous: prev_graph,
colors: DepNodeColorMap::new(prev_graph_node_count),
loaded_from_cache: Default::default(),
})),
}
}
@@ -874,25 +870,6 @@ impl DepGraph {
}
}
}

pub fn mark_loaded_from_cache(&self, dep_node_index: DepNodeIndex, state: bool) {
debug!("mark_loaded_from_cache({:?}, {})",
self.data.as_ref().unwrap().current.borrow().data[dep_node_index].node,
state);

self.data
.as_ref()
.unwrap()
.loaded_from_cache
.borrow_mut()
.insert(dep_node_index, state);
}

pub fn was_loaded_from_cache(&self, dep_node: &DepNode) -> Option<bool> {
let data = self.data.as_ref().unwrap();
let dep_node_index = data.current.borrow().node_to_node_index[dep_node];
data.loaded_from_cache.borrow().get(&dep_node_index).cloned()
}
}

/// A "work product" is an intermediate result that we save into the
43 changes: 41 additions & 2 deletions src/librustc/error_codes.rs
Original file line number Diff line number Diff line change
@@ -1520,6 +1520,47 @@ where
```
"##,

E0495: r##"
A lifetime cannot be determined in the given situation.
Erroneous code example:
```compile_fail,E0495
fn transmute_lifetime<'a, 'b, T>(t: &'a (T,)) -> &'b T {
match (&t,) { // error!
((u,),) => u,
}
}
let y = Box::new((42,));
let x = transmute_lifetime(&y);
```
In this code, you have two ways to solve this issue:
1. Enforce that `'a` lives at least as long as `'b`.
2. Use the same lifetime requirement for both input and output values.
So for the first solution, you can do it by replacing `'a` with `'a: 'b`:
```
fn transmute_lifetime<'a: 'b, 'b, T>(t: &'a (T,)) -> &'b T {
match (&t,) { // ok!
((u,),) => u,
}
}
```
In the second you can do it by simply removing `'b` so they both use `'a`:
```
fn transmute_lifetime<'a, T>(t: &'a (T,)) -> &'a T {
match (&t,) { // ok!
((u,),) => u,
}
}
```
"##,

E0496: r##"
A lifetime name is shadowing another lifetime name. Erroneous code example:
@@ -2116,8 +2157,6 @@ rejected in your own crates.
E0488, // lifetime of variable does not enclose its declaration
E0489, // type/lifetime parameter not in scope here
E0490, // a value of type `..` is borrowed for too long
E0495, // cannot infer an appropriate lifetime due to conflicting
// requirements
E0623, // lifetime mismatch where both parameters are anonymous regions
E0628, // generators cannot have explicit parameters
E0631, // type mismatch in closure arguments
53 changes: 13 additions & 40 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
@@ -489,10 +489,6 @@ impl<'tcx> TyCtxt<'tcx> {
self.incremental_verify_ich::<Q>(&result, dep_node, dep_node_index);
}

if unlikely!(self.sess.opts.debugging_opts.query_dep_graph) {
self.dep_graph.mark_loaded_from_cache(dep_node_index, true);
}

result
}

@@ -570,10 +566,6 @@ impl<'tcx> TyCtxt<'tcx> {
drop(prof_timer);
profq_msg!(self, ProfileQueriesMsg::ProviderEnd);

if unlikely!(self.sess.opts.debugging_opts.query_dep_graph) {
self.dep_graph.mark_loaded_from_cache(dep_node_index, false);
}

if unlikely!(!diagnostics.is_empty()) {
if dep_node.kind != crate::dep_graph::DepKind::Null {
self.queries.on_disk_cache
@@ -1191,37 +1183,6 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
return false
}

macro_rules! def_id {
() => {
if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
}
}
};

macro_rules! krate {
() => { (def_id!()).krate }
};

macro_rules! force_ex {
($tcx:expr, $query:ident, $key:expr) => {
{
$tcx.force_query::<crate::ty::query::queries::$query<'_>>(
$key,
DUMMY_SP,
*dep_node
);
}
}
};

macro_rules! force {
($query:ident, $key:expr) => { force_ex!(tcx, $query, $key) }
};

rustc_dep_node_force!([dep_node, tcx]
// These are inputs that are expected to be pre-allocated and that
// should therefore always be red or green already.
@@ -1240,7 +1201,19 @@ pub fn force_from_dep_node(tcx: TyCtxt<'_>, dep_node: &DepNode) -> bool {
bug!("force_from_dep_node: encountered {:?}", dep_node)
}

DepKind::Analysis => { force!(analysis, krate!()); }
DepKind::Analysis => {
let def_id = if let Some(def_id) = dep_node.extract_def_id(tcx) {
def_id
} else {
// Return from the whole function.
return false
};
tcx.force_query::<crate::ty::query::queries::analysis<'_>>(
def_id.krate,
DUMMY_SP,
*dep_node
);
}
);

true
10 changes: 6 additions & 4 deletions src/librustc_codegen_llvm/attributes.rs
Original file line number Diff line number Diff line change
@@ -96,10 +96,12 @@ pub fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
}

// Currently stack probes seem somewhat incompatible with the address
// sanitizer. With asan we're already protected from stack overflow anyway
// so we don't really need stack probes regardless.
if let Some(Sanitizer::Address) = cx.sess().opts.debugging_opts.sanitizer {
return
// sanitizer and thread sanitizer. With asan we're already protected from
// stack overflow anyway so we don't really need stack probes regardless.
match cx.sess().opts.debugging_opts.sanitizer {
Some(Sanitizer::Address) |
Some(Sanitizer::Thread) => return,
_ => {},
}

// probestack doesn't play nice either with `-C profile-generate`.
2 changes: 1 addition & 1 deletion src/librustc_errors/styled_buffer.rs
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ impl StyledBuffer {

pub fn prepend(&mut self, line: usize, string: &str, style: Style) {
self.ensure_lines(line);
let string_len = string.len();
let string_len = string.chars().count();

// Push the old content over to make room for new content
for _ in 0..string_len {
6 changes: 5 additions & 1 deletion src/librustc_macros/src/query.rs
Original file line number Diff line number Diff line change
@@ -495,7 +495,11 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
dep_node_force_stream.extend(quote! {
DepKind::#name => {
if let Some(key) = RecoverKey::recover($tcx, $dep_node) {
force_ex!($tcx, #name, key);
$tcx.force_query::<crate::ty::query::queries::#name<'_>>(
key,
DUMMY_SP,
*$dep_node
);
} else {
return false;
}
29 changes: 28 additions & 1 deletion src/librustc_passes/error_codes.rs
Original file line number Diff line number Diff line change
@@ -314,6 +314,34 @@ type A3 = fn(i16); // ok!
```
"##,

E0567: r##"
Generics have been used on an auto trait.
Erroneous code example:
```compile_fail,E0567
#![feature(optin_builtin_traits)]
auto trait Generic<T> {} // error!
fn main() {}
```
Since an auto trait is implemented on all existing types, the
compiler would not be able to infer the types of the trait's generic
parameters.
To fix this issue, just remove the generics:
```
#![feature(optin_builtin_traits)]
auto trait Generic {} // ok!
fn main() {}
```
"##,

E0571: r##"
A `break` statement with an argument appeared in a non-`loop` loop.
@@ -531,7 +559,6 @@ Switch to the Rust 2018 edition to use `async fn`.
;
E0226, // only a single explicit lifetime bound is permitted
E0472, // asm! is unsupported on this target
E0567, // auto traits can not have generic parameters
E0568, // auto traits can not have super traits
E0666, // nested `impl Trait` is illegal
E0667, // `impl Trait` in projections
44 changes: 36 additions & 8 deletions src/librustc_typeck/check/method/suggest.rs
Original file line number Diff line number Diff line change
@@ -461,16 +461,36 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
err.span_label(span, "this is an associated function, not a method");
}
if static_sources.len() == 1 {
let ty_str = if let Some(CandidateSource::ImplSource(
impl_did,
)) = static_sources.get(0) {
// When the "method" is resolved through dereferencing, we really want the
// original type that has the associated function for accurate suggestions.
// (#61411)
let ty = self.impl_self_ty(span, *impl_did).ty;
match (&ty.peel_refs().kind, &actual.peel_refs().kind) {
(ty::Adt(def, _), ty::Adt(def_actual, _)) if def == def_actual => {
// Use `actual` as it will have more `substs` filled in.
self.ty_to_value_string(actual.peel_refs())
}
_ => self.ty_to_value_string(ty.peel_refs()),
}
} else {
self.ty_to_value_string(actual.peel_refs())
};
if let SelfSource::MethodCall(expr) = source {
err.span_suggestion(expr.span.to(span),
"use associated function syntax instead",
format!("{}::{}",
self.ty_to_string(actual),
item_name),
Applicability::MachineApplicable);
err.span_suggestion(
expr.span.to(span),
"use associated function syntax instead",
format!("{}::{}", ty_str, item_name),
Applicability::MachineApplicable,
);
} else {
err.help(&format!("try with `{}::{}`",
self.ty_to_string(actual), item_name));
err.help(&format!(
"try with `{}::{}`",
ty_str,
item_name,
));
}

report_candidates(span, &mut err, static_sources);
@@ -586,6 +606,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
None
}

/// Print out the type for use in value namespace.
fn ty_to_value_string(&self, ty: Ty<'tcx>) -> String {
match ty.kind {
ty::Adt(def, substs) => format!("{}", ty::Instance::new(def.did, substs)),
_ => self.ty_to_string(ty),
}
}

fn suggest_use_candidates(&self,
err: &mut DiagnosticBuilder<'_>,
mut msg: String,
20 changes: 19 additions & 1 deletion src/libsyntax/error_codes.rs
Original file line number Diff line number Diff line change
@@ -163,6 +163,25 @@ fn the_banished() {} // ok!
```
"##,

E0551: r##"
An invalid meta-item was used inside an attribute.
Erroneous code example:
```compile_fail,E0551
#[deprecated(note)] // error!
fn i_am_deprecated() {}
```
Meta items are the key-value pairs inside of an attribute. To fix this issue,
you need to give a value to the `note` key. Example:
```
#[deprecated(note = "because")] // ok!
fn i_am_deprecated() {}
```
"##,

E0552: r##"
A unrecognized representation attribute was used.
@@ -473,7 +492,6 @@ features in the `-Z allow_features` flag.
// rustc_deprecated attribute must be paired with either stable or unstable
// attribute
E0549,
E0551, // incorrect meta item
E0553, // multiple rustc_const_unstable attributes
// E0555, // replaced with a generic attribute input check
E0584, // file for module `..` found at both .. and ..
Original file line number Diff line number Diff line change
@@ -23,3 +23,4 @@ LL | bar(foo, x)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
Original file line number Diff line number Diff line change
@@ -19,3 +19,4 @@ LL | fn baz<'a,'b>(x: Type<'a>) -> Type<'static> {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
3 changes: 2 additions & 1 deletion src/test/ui/auto-trait-validation.stderr
Original file line number Diff line number Diff line change
@@ -18,4 +18,5 @@ LL | auto trait MyTrait { fn foo() {} }

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0380`.
Some errors have detailed explanations: E0380, E0567.
For more information about an error, try `rustc --explain E0380`.
3 changes: 2 additions & 1 deletion src/test/ui/c-variadic/variadic-ffi-4.stderr
Original file line number Diff line number Diff line change
@@ -209,4 +209,5 @@ LL | | }

error: aborting due to 8 previous errors

For more information about this error, try `rustc --explain E0308`.
Some errors have detailed explanations: E0308, E0495.
For more information about an error, try `rustc --explain E0308`.
2 changes: 1 addition & 1 deletion src/test/ui/deprecation/deprecation-sanity.stderr
Original file line number Diff line number Diff line change
@@ -54,5 +54,5 @@ LL | #[deprecated(since = "a", since = "b", note = "c")]

error: aborting due to 9 previous errors

Some errors have detailed explanations: E0538, E0541, E0550, E0565.
Some errors have detailed explanations: E0538, E0541, E0550, E0551, E0565.
For more information about an error, try `rustc --explain E0538`.
Original file line number Diff line number Diff line change
@@ -27,3 +27,4 @@ LL | invoke(&x, |a, b| if a > b { a } else { b });

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
1 change: 1 addition & 0 deletions src/test/ui/impl-header-lifetime-elision/dyn-trait.stderr
Original file line number Diff line number Diff line change
@@ -19,3 +19,4 @@ LL | fn with_dyn_debug_static<'a>(x: Box<dyn Debug + 'a>) {

error: aborting due to previous error

For more information about this error, try `rustc --explain E0495`.
Loading

0 comments on commit 2748a9f

Please sign in to comment.