Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
68d099a
Create new error code E0734 for stability attributes used outside of …
GuillaumeGomez Sep 25, 2019
0ec4513
Fix format macro expansions spans to be macro-generated
rinon Sep 25, 2019
0ebb044
Add long error explanation for E0734
GuillaumeGomez Sep 25, 2019
2e78683
Update ui tests
GuillaumeGomez Sep 25, 2019
ecfe92f
Don't check error_codes files for lints
GuillaumeGomez Sep 27, 2019
ac9aed5
getting more context for duplicate lang items (fixes #60561)
tomtau Sep 27, 2019
f922483
Print ParamTy span when accessing a field (#52082)
Baranowski Sep 26, 2019
d35f25c
Filter out stmts made for the redundant_semicolon lint when pretty-pr…
nathanwhit Sep 12, 2019
66c33c0
Add test for redundant_semicolon lint interaction with proc macro attrs
nathanwhit Sep 28, 2019
800bd3a
data_structures: Add deterministic FxHashMap and FxHashSet wrappers
inashivb Sep 3, 2019
fd505d7
Improve wording in documentation of MaybeUninit
nliberg Sep 27, 2019
f3744a1
Implement CRs
Baranowski Sep 28, 2019
9ad99c3
Refactor into ban_nonexisting_field method
Baranowski Sep 28, 2019
f6cecce
Upgrade async/await to "used" keywords.
ehuss Sep 28, 2019
c666bd5
Fix typo in intrinsics op safety
vertexclique Sep 28, 2019
e77dfa2
Slice docs: fix typo
llogiq Sep 28, 2019
b18d861
Rollup merge of #64131 - shivan1b:deterministic-fxhashmap, r=Mark-Sim…
Centril Sep 28, 2019
55a3ead
Rollup merge of #64387 - nathanwhit:redundant-semi-fix, r=varkor
Centril Sep 28, 2019
05881d0
Rollup merge of #64678 - tomtau:fix/no-std-error, r=matthewjasper
Centril Sep 28, 2019
01075d8
Rollup merge of #64763 - GuillaumeGomez:long-err-explanation-E0734, r…
Centril Sep 28, 2019
d9168e4
Rollup merge of #64793 - immunant:format_spans, r=matthewjasper
Centril Sep 28, 2019
69a3009
Rollup merge of #64837 - nliberg:patch-2, r=Centril
Centril Sep 28, 2019
6145757
Rollup merge of #64852 - Baranowski:param_note_52082, r=estebank
Centril Sep 28, 2019
787829d
Rollup merge of #64875 - ehuss:async-await-reserved, r=estebank
Centril Sep 28, 2019
1c2dd14
Rollup merge of #64876 - vertexclique:vcq/fix-fn-name-intrinsic-op-un…
Centril Sep 28, 2019
4652671
Rollup merge of #64880 - llogiq:slice-docs, r=Centril
Centril Sep 28, 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
Prev Previous commit
Next Next commit
getting more context for duplicate lang items (fixes #60561)
Where possible, the error message includes the name of the crate
that brought in the crate with duplicate lang items (which
helps with debugging). This information is passed on from cstore
using the `extern_crate` query.
  • Loading branch information
tomtau committed Sep 27, 2019
commit ac9aed56e4dc62c4959ae0c14cec585994302c93
9 changes: 8 additions & 1 deletion src/librustc/middle/cstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,17 @@ pub struct ExternCrate {
/// used to select the extern with the shortest path
pub path_len: usize,

/// Crate that depends on this crate
pub dependency_of: CrateNum,
}

impl ExternCrate {
/// If true, then this crate is the crate named by the extern
/// crate referenced above. If false, then this crate is a dep
/// of the crate.
pub direct: bool,
pub fn is_direct(&self) -> bool {
self.dependency_of == LOCAL_CRATE
}
}

#[derive(Copy, Clone, Debug, HashStable)]
Expand Down
34 changes: 29 additions & 5 deletions src/librustc/middle/lang_items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::hir::def_id::DefId;
use crate::hir::check_attr::Target;
use crate::ty::{self, TyCtxt};
use crate::middle::weak_lang_items;
use crate::middle::cstore::ExternCrate;
use crate::util::nodemap::FxHashMap;

use syntax::ast;
Expand Down Expand Up @@ -182,16 +183,39 @@ impl LanguageItemCollector<'tcx> {
E0152,
"duplicate lang item found: `{}`.",
name),
None => self.tcx.sess.struct_err(&format!(
"duplicate lang item in crate `{}`: `{}`.",
self.tcx.crate_name(item_def_id.krate),
name)),
None => {
match self.tcx.extern_crate(item_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
self.tcx.sess.struct_err(&format!(
"duplicate lang item in crate `{}` (which `{}` depends on): `{}`.",
self.tcx.crate_name(item_def_id.krate),
self.tcx.crate_name(*dependency_of),
name))
},
_ => {
self.tcx.sess.struct_err(&format!(
"duplicate lang item in crate `{}`: `{}`.",
self.tcx.crate_name(item_def_id.krate),
name))
}
}
},
};
if let Some(span) = self.tcx.hir().span_if_local(original_def_id) {
span_note!(&mut err, span, "first defined here.");
} else {
err.note(&format!("first defined in crate `{}`.",
match self.tcx.extern_crate(original_def_id) {
Some(ExternCrate {dependency_of, ..}) => {
err.note(&format!(
"first defined in crate `{}` (which `{}` depends on).",
self.tcx.crate_name(original_def_id.krate),
self.tcx.crate_name(*dependency_of)));
},
_ => {
err.note(&format!("first defined in crate `{}`.",
self.tcx.crate_name(original_def_id.krate)));
}
}
}
err.emit();
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ pub trait PrettyPrinter<'tcx>:
match self.tcx().extern_crate(def_id) {
Some(&ExternCrate {
src: ExternCrateSource::Extern(def_id),
direct: true,
dependency_of: LOCAL_CRATE,
span,
..
}) => {
Expand Down
15 changes: 8 additions & 7 deletions src/librustc_metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use rustc::middle::cstore::{ExternCrate, ExternCrateSource};
use rustc::util::common::record_time;
use rustc::util::nodemap::FxHashSet;
use rustc::hir::map::Definitions;
use rustc::hir::def_id::LOCAL_CRATE;

use std::ops::Deref;
use std::path::PathBuf;
Expand Down Expand Up @@ -430,7 +431,7 @@ impl<'a> CrateLoader<'a> {
mut extern_crate: ExternCrate,
visited: &mut FxHashSet<(CrateNum, bool)>)
{
if !visited.insert((cnum, extern_crate.direct)) { return }
if !visited.insert((cnum, extern_crate.is_direct())) { return }

let cmeta = self.cstore.get_crate_data(cnum);
let mut old_extern_crate = cmeta.extern_crate.borrow_mut();
Expand All @@ -441,14 +442,14 @@ impl<'a> CrateLoader<'a> {
// - shorter paths to longer (tuple.2).
let new_rank = (
true,
extern_crate.direct,
extern_crate.is_direct(),
cmp::Reverse(extern_crate.path_len),
);
let old_rank = match *old_extern_crate {
None => (false, false, cmp::Reverse(usize::max_value())),
Some(ref c) => (
true,
c.direct,
c.is_direct(),
cmp::Reverse(c.path_len),
),
};
Expand All @@ -460,7 +461,7 @@ impl<'a> CrateLoader<'a> {
drop(old_extern_crate);

// Propagate the extern crate info to dependencies.
extern_crate.direct = false;
extern_crate.dependency_of = cnum;
for &dep_cnum in cmeta.dependencies.borrow().iter() {
self.update_extern_crate(dep_cnum, extern_crate, visited);
}
Expand Down Expand Up @@ -1030,7 +1031,7 @@ impl<'a> CrateLoader<'a> {
src: ExternCrateSource::Extern(def_id),
span: item.span,
path_len,
direct: true,
dependency_of: LOCAL_CRATE,
},
&mut FxHashSet::default(),
);
Expand All @@ -1057,7 +1058,7 @@ impl<'a> CrateLoader<'a> {
span,
// to have the least priority in `update_extern_crate`
path_len: usize::max_value(),
direct: true,
dependency_of: LOCAL_CRATE,
},
&mut FxHashSet::default(),
);
Expand All @@ -1081,7 +1082,7 @@ impl<'a> CrateLoader<'a> {
span,
// to have the least priority in `update_extern_crate`
path_len: usize::max_value(),
direct: true,
dependency_of: LOCAL_CRATE,
},
&mut FxHashSet::default(),
);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_metadata/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,

missing_extern_crate_item => {
let r = match *cdata.extern_crate.borrow() {
Some(extern_crate) if !extern_crate.direct => true,
Some(extern_crate) if !extern_crate.is_direct() => true,
_ => false,
};
r
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/duplicate_entry_error.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LL | | loop {}
LL | | }
| |_^
|
= note: first defined in crate `std`.
= note: first defined in crate `std` (which `duplicate_entry_error` depends on).

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/error-codes/E0152.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ error[E0152]: duplicate lang item found: `arc`.
LL | struct Foo;
| ^^^^^^^^^^^
|
= note: first defined in crate `alloc`.
= note: first defined in crate `alloc` (which `std` depends on).

error: aborting due to previous error

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/panic-handler/panic-handler-std.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | | loop {}
LL | | }
| |_^
|
= note: first defined in crate `std`.
= note: first defined in crate `std` (which `panic_handler_std` depends on).

error: argument should be `&PanicInfo`
--> $DIR/panic-handler-std.rs:7:16
Expand Down