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 9 pull requests #65723

Closed
wants to merge 44 commits into from
Closed
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
47a443c
Duplicate lint specifications are always bug!
Mark-Simulacrum Sep 24, 2019
577d442
De-propagate optional session from lint registration
Mark-Simulacrum Sep 24, 2019
2121b04
Handle lints, not passes in push_lints
Mark-Simulacrum Sep 24, 2019
748eccd
Lints being from a plugin is dependent on the lint, not the registration
Mark-Simulacrum Oct 7, 2019
b060f3b
Split module and crate late pass registration
Mark-Simulacrum Oct 7, 2019
e1079c8
Split out just registration to separate function
Mark-Simulacrum Oct 7, 2019
68c07db
No longer implicitly register lints when registering passes
Mark-Simulacrum Oct 7, 2019
7fef397
Make get_lints be a static function
Mark-Simulacrum Oct 7, 2019
2454512
Take lint passes as constructor functions
Mark-Simulacrum Oct 7, 2019
aa4ee2c
Move to storing constructor functions inside LintStore
Mark-Simulacrum Oct 7, 2019
c1abc30
Make declare_lint take any amount of boolean fields
Mark-Simulacrum Oct 8, 2019
7abb1fa
Remove side table of future incompatibility info
Mark-Simulacrum Oct 9, 2019
c4475c7
Access future incompatibility information directly
Mark-Simulacrum Oct 9, 2019
da56d1d
Remove all borrows of lint store from Session from librustc
Mark-Simulacrum Oct 9, 2019
dab3bd6
Create lint store during plugin registration
Mark-Simulacrum Oct 9, 2019
b761367
Fix test fallout
Mark-Simulacrum Oct 9, 2019
6be0a70
Update API to be more compatible with plugin needs
Mark-Simulacrum Oct 10, 2019
c290293
Derive `Rustc{En,De}codable` for `TokenStream`.
nnethercote Oct 15, 2019
02edd14
Convert some `InternedString`s to `Symbols`.
nnethercote Oct 18, 2019
c325553
Convert `InternedString`s to `Symbols` in `UnsafetyViolation`.
nnethercote Oct 18, 2019
78c3427
Remove unnecessary `impl Clean<String> for InternedString`.
nnethercote Oct 19, 2019
ddc1c27
Eliminate `intersect_opt`.
nnethercote Sep 19, 2019
b8214e9
Convert fields within `DefPathData` from `InternedString` to `Symbol`.
nnethercote Oct 21, 2019
dddacf1
Change `SymbolName::name` from `InternedString` to `Symbol`.
nnethercote Oct 21, 2019
2da7a9c
Use `Symbol` for codegen unit names.
nnethercote Oct 21, 2019
08e2f05
Remove `InternedString`.
nnethercote Oct 21, 2019
33910f9
Deprecated proc_macro doesn't trigger warning on build library
XiangQingW Oct 21, 2019
c027be0
Deprecated proc_macro doesn't trigger warning on build library
XiangQingW Oct 21, 2019
ed965f1
Update E0659 error code long explanation to 2018 edition
GuillaumeGomez Oct 22, 2019
74db3e8
rustc_metadata: use a table for super_predicates.
eddyb Oct 18, 2019
7a80a11
rustc_metadata: use a table for fn_sig.
eddyb Oct 18, 2019
371cc39
rustc_metadata: use a table for impl_trait_ref.
eddyb Oct 18, 2019
fe84809
relax ExactSizeIterator bound on write_bytes: too many iterators don'…
RalfJung Oct 22, 2019
4e8d1b2
Add some documentation
Mark-Simulacrum Oct 22, 2019
eeb549b
Add Cow::is_borrowed and Cow::is_owned
clarfonthey Oct 5, 2019
360cdf4
Rollup merge of #65144 - clarfon:moo, r=sfackler
Centril Oct 23, 2019
2cb7d20
Rollup merge of #65193 - Mark-Simulacrum:lockless-lintstore, r=nikoma…
Centril Oct 23, 2019
d41bf54
Rollup merge of #65583 - eddyb:more-query-like-cross-crate-tables, r=…
Centril Oct 23, 2019
dd47daf
Rollup merge of #65641 - nnethercote:derive-TokenStream-Encodable-Dec…
Centril Oct 23, 2019
d8015f6
Rollup merge of #65648 - nnethercote:rm-intersect_opt, r=nikomatsakis
Centril Oct 23, 2019
c020d64
Rollup merge of #65657 - nnethercote:rm-InternedString-properly, r=eddyb
Centril Oct 23, 2019
cea5879
Rollup merge of #65666 - XiangQingW:proc_macro, r=petrochenkov
Centril Oct 23, 2019
9bcebab
Rollup merge of #65691 - GuillaumeGomez:2018-edition-E0659, r=Dylan-DPC
Centril Oct 23, 2019
fe3eb32
Rollup merge of #65704 - RalfJung:exact-size, r=oli-obk
Centril Oct 23, 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 @@ -3483,6 +3483,7 @@ dependencies = [
"rustc_data_structures",
"rustc_errors",
"rustc_interface",
"rustc_lint",
"rustc_metadata",
"rustc_mir",
"rustc_plugin",
Expand Down
41 changes: 41 additions & 0 deletions src/liballoc/borrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,47 @@ impl<B: ?Sized + ToOwned> Clone for Cow<'_, B> {
}

impl<B: ?Sized + ToOwned> Cow<'_, B> {
/// Returns true if the data is borrowed, i.e. if `to_mut` would require additional work.
///
/// # Examples
///
/// ```
/// #![feature(cow_is_borrowed)]
/// use std::borrow::Cow;
///
/// let cow = Cow::Borrowed("moo");
/// assert!(cow.is_borrowed());
///
/// let bull: Cow<'_, str> = Cow::Owned("...moo?".to_string());
/// assert!(!bull.is_borrowed());
/// ```
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
pub fn is_borrowed(&self) -> bool {
match *self {
Borrowed(_) => true,
Owned(_) => false,
}
}

/// Returns true if the data is owned, i.e. if `to_mut` would be a no-op.
///
/// # Examples
///
/// ```
/// #![feature(cow_is_borrowed)]
/// use std::borrow::Cow;
///
/// let cow: Cow<'_, str> = Cow::Owned("moo".to_string());
/// assert!(cow.is_owned());
///
/// let bull = Cow::Borrowed("...moo?");
/// assert!(!bull.is_owned());
/// ```
#[unstable(feature = "cow_is_borrowed", issue = "65143")]
pub fn is_owned(&self) -> bool {
!self.is_borrowed()
}

/// Acquires a mutable reference to the owned form of the data.
///
/// Clones the data if it is not already owned.
Expand Down
1 change: 1 addition & 0 deletions src/liballoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
#![feature(const_generic_impls_guard)]
#![feature(const_generics)]
#![feature(const_in_array_repeat_expressions)]
#![feature(cow_is_borrowed)]
#![feature(dispatch_from_dyn)]
#![feature(core_intrinsics)]
#![feature(container_error_extra)]
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ use crate::ich::{Fingerprint, StableHashingContext};
use rustc_data_structures::stable_hasher::{StableHasher, HashStable};
use std::fmt;
use std::hash::Hash;
use syntax_pos::symbol::InternedString;
use syntax_pos::symbol::Symbol;
use crate::traits;
use crate::traits::query::{
CanonicalProjectionGoal, CanonicalTyGoal, CanonicalTypeOpAscribeUserTypeGoal,
Expand Down Expand Up @@ -426,7 +426,7 @@ rustc_dep_node_append!([define_dep_nodes!][ <'tcx>

[anon] TraitSelect,

[] CompileCodegenUnit(InternedString),
[] CompileCodegenUnit(Symbol),

[eval_always] Analysis(CrateNum),
]);
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,15 +792,15 @@ impl<'a> LoweringContext<'a> {
// really show up for end-user.
let (str_name, kind) = match hir_name {
ParamName::Plain(ident) => (
ident.as_interned_str(),
ident.name,
hir::LifetimeParamKind::InBand,
),
ParamName::Fresh(_) => (
kw::UnderscoreLifetime.as_interned_str(),
kw::UnderscoreLifetime,
hir::LifetimeParamKind::Elided,
),
ParamName::Error => (
kw::UnderscoreLifetime.as_interned_str(),
kw::UnderscoreLifetime,
hir::LifetimeParamKind::Error,
),
};
Expand Down Expand Up @@ -1590,7 +1590,7 @@ impl<'a> LoweringContext<'a> {
self.context.resolver.definitions().create_def_with_parent(
self.parent,
def_node_id,
DefPathData::LifetimeNs(name.ident().as_interned_str()),
DefPathData::LifetimeNs(name.ident().name),
ExpnId::root(),
lifetime.span);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
});

let mut upstream_crates: Vec<_> = cstore.crates_untracked().iter().map(|&cnum| {
let name = cstore.crate_name_untracked(cnum).as_interned_str();
let name = cstore.crate_name_untracked(cnum);
let disambiguator = cstore.crate_disambiguator_untracked(cnum).to_fingerprint();
let hash = cstore.crate_hash_untracked(cnum);
(name, disambiguator, hash)
}).collect();

upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name, dis));
upstream_crates.sort_unstable_by_key(|&(name, dis, _)| (name.as_str(), dis));

// We hash the final, remapped names of all local source files so we
// don't have to include the path prefix remapping commandline args.
Expand Down
29 changes: 13 additions & 16 deletions src/librustc/hir/map/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl<'a> DefCollector<'a> {

// For async functions, we need to create their inner defs inside of a
// closure to match their desugared representation.
let fn_def_data = DefPathData::ValueNs(name.as_interned_str());
let fn_def_data = DefPathData::ValueNs(name);
let fn_def = self.create_def(id, fn_def_data, span);
return self.with_parent(fn_def, |this| {
this.create_def(return_impl_trait_id, DefPathData::ImplTrait, span);
Expand All @@ -83,8 +83,7 @@ impl<'a> DefCollector<'a> {
.unwrap_or_else(|| {
let node_id = NodeId::placeholder_from_expn_id(self.expansion);
sym::integer(self.definitions.placeholder_field_indices[&node_id])
})
.as_interned_str();
});
let def = self.create_def(field.id, DefPathData::ValueNs(name), field.span);
self.with_parent(def, |this| visit::walk_struct_field(this, field));
}
Expand All @@ -109,7 +108,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
ItemKind::Mod(..) | ItemKind::Trait(..) | ItemKind::TraitAlias(..) |
ItemKind::Enum(..) | ItemKind::Struct(..) | ItemKind::Union(..) |
ItemKind::OpaqueTy(..) | ItemKind::ExternCrate(..) | ItemKind::ForeignMod(..) |
ItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.as_interned_str()),
ItemKind::TyAlias(..) => DefPathData::TypeNs(i.ident.name),
ItemKind::Fn(
ref decl,
ref header,
Expand All @@ -127,8 +126,8 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
)
}
ItemKind::Static(..) | ItemKind::Const(..) | ItemKind::Fn(..) =>
DefPathData::ValueNs(i.ident.as_interned_str()),
ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.as_interned_str()),
DefPathData::ValueNs(i.ident.name),
ItemKind::MacroDef(..) => DefPathData::MacroNs(i.ident.name),
ItemKind::Mac(..) => return self.visit_macro_invoc(i.id),
ItemKind::GlobalAsm(..) => DefPathData::Misc,
ItemKind::Use(..) => {
Expand Down Expand Up @@ -162,7 +161,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
}

let def = self.create_def(foreign_item.id,
DefPathData::ValueNs(foreign_item.ident.as_interned_str()),
DefPathData::ValueNs(foreign_item.ident.name),
foreign_item.span);

self.with_parent(def, |this| {
Expand All @@ -175,7 +174,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
return self.visit_macro_invoc(v.id);
}
let def = self.create_def(v.id,
DefPathData::TypeNs(v.ident.as_interned_str()),
DefPathData::TypeNs(v.ident.name),
v.span);
self.with_parent(def, |this| {
if let Some(ctor_hir_id) = v.data.ctor_id() {
Expand All @@ -202,7 +201,7 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
self.visit_macro_invoc(param.id);
return;
}
let name = param.ident.as_interned_str();
let name = param.ident.name;
let def_path_data = match param.kind {
GenericParamKind::Lifetime { .. } => DefPathData::LifetimeNs(name),
GenericParamKind::Type { .. } => DefPathData::TypeNs(name),
Expand All @@ -216,9 +215,9 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
fn visit_trait_item(&mut self, ti: &'a TraitItem) {
let def_data = match ti.kind {
TraitItemKind::Method(..) | TraitItemKind::Const(..) =>
DefPathData::ValueNs(ti.ident.as_interned_str()),
DefPathData::ValueNs(ti.ident.name),
TraitItemKind::Type(..) => {
DefPathData::TypeNs(ti.ident.as_interned_str())
DefPathData::TypeNs(ti.ident.name)
},
TraitItemKind::Macro(..) => return self.visit_macro_invoc(ti.id),
};
Expand All @@ -243,12 +242,10 @@ impl<'a> visit::Visitor<'a> for DefCollector<'a> {
body,
)
}
ImplItemKind::Method(..) | ImplItemKind::Const(..) =>
DefPathData::ValueNs(ii.ident.as_interned_str()),
ImplItemKind::Method(..) |
ImplItemKind::Const(..) => DefPathData::ValueNs(ii.ident.name),
ImplItemKind::TyAlias(..) |
ImplItemKind::OpaqueTy(..) => {
DefPathData::TypeNs(ii.ident.as_interned_str())
},
ImplItemKind::OpaqueTy(..) => DefPathData::TypeNs(ii.ident.name),
ImplItemKind::Macro(..) => return self.visit_macro_invoc(ii.id),
};

Expand Down
44 changes: 22 additions & 22 deletions src/librustc/hir/map/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use std::fmt::Write;
use std::hash::Hash;
use syntax::ast;
use syntax_expand::hygiene::ExpnId;
use syntax::symbol::{Symbol, sym, InternedString};
use syntax::symbol::{Symbol, sym};
use syntax_pos::{Span, DUMMY_SP};

/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
Expand Down Expand Up @@ -136,7 +136,9 @@ impl DefKey {

::std::mem::discriminant(data).hash(&mut hasher);
if let Some(name) = data.get_opt_name() {
name.hash(&mut hasher);
// Get a stable hash by considering the symbol chars rather than
// the symbol index.
name.as_str().hash(&mut hasher);
}

disambiguator.hash(&mut hasher);
Expand Down Expand Up @@ -218,7 +220,7 @@ impl DefPath {
for component in &self.data {
write!(s,
"::{}[{}]",
component.data.as_interned_str(),
component.data.as_symbol(),
component.disambiguator)
.unwrap();
}
Expand All @@ -238,11 +240,11 @@ impl DefPath {

for component in &self.data {
if component.disambiguator == 0 {
write!(s, "::{}", component.data.as_interned_str()).unwrap();
write!(s, "::{}", component.data.as_symbol()).unwrap();
} else {
write!(s,
"{}[{}]",
component.data.as_interned_str(),
component.data.as_symbol(),
component.disambiguator)
.unwrap();
}
Expand All @@ -262,11 +264,11 @@ impl DefPath {
opt_delimiter.map(|d| s.push(d));
opt_delimiter = Some('-');
if component.disambiguator == 0 {
write!(s, "{}", component.data.as_interned_str()).unwrap();
write!(s, "{}", component.data.as_symbol()).unwrap();
} else {
write!(s,
"{}[{}]",
component.data.as_interned_str(),
component.data.as_symbol(),
component.disambiguator)
.unwrap();
}
Expand All @@ -290,13 +292,13 @@ pub enum DefPathData {
/// An impl.
Impl,
/// Something in the type namespace.
TypeNs(InternedString),
TypeNs(Symbol),
/// Something in the value namespace.
ValueNs(InternedString),
ValueNs(Symbol),
/// Something in the macro namespace.
MacroNs(InternedString),
MacroNs(Symbol),
/// Something in the lifetime namespace.
LifetimeNs(InternedString),
LifetimeNs(Symbol),
/// A closure expression.
ClosureExpr,

Expand All @@ -311,7 +313,7 @@ pub enum DefPathData {
/// Identifies a piece of crate metadata that is global to a whole crate
/// (as opposed to just one item). `GlobalMetaData` components are only
/// supposed to show up right below the crate root.
GlobalMetaData(InternedString),
GlobalMetaData(Symbol),
}

#[derive(Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Debug,
Expand Down Expand Up @@ -545,7 +547,7 @@ impl Definitions {
}

impl DefPathData {
pub fn get_opt_name(&self) -> Option<InternedString> {
pub fn get_opt_name(&self) -> Option<Symbol> {
use self::DefPathData::*;
match *self {
TypeNs(name) |
Expand All @@ -564,15 +566,15 @@ impl DefPathData {
}
}

pub fn as_interned_str(&self) -> InternedString {
pub fn as_symbol(&self) -> Symbol {
use self::DefPathData::*;
let s = match *self {
match *self {
TypeNs(name) |
ValueNs(name) |
MacroNs(name) |
LifetimeNs(name) |
GlobalMetaData(name) => {
return name
name
}
// Note that this does not show up in user print-outs.
CrateRoot => sym::double_braced_crate,
Expand All @@ -582,13 +584,11 @@ impl DefPathData {
Ctor => sym::double_braced_constructor,
AnonConst => sym::double_braced_constant,
ImplTrait => sym::double_braced_opaque,
};

s.as_interned_str()
}
}

pub fn to_string(&self) -> String {
self.as_interned_str().to_string()
self.as_symbol().to_string()
}
}

Expand All @@ -610,7 +610,7 @@ macro_rules! define_global_metadata_kind {
definitions.create_def_with_parent(
CRATE_DEF_INDEX,
ast::DUMMY_NODE_ID,
DefPathData::GlobalMetaData(instance.name().as_interned_str()),
DefPathData::GlobalMetaData(instance.name()),
ExpnId::root(),
DUMMY_SP
);
Expand All @@ -624,7 +624,7 @@ macro_rules! define_global_metadata_kind {
let def_key = DefKey {
parent: Some(CRATE_DEF_INDEX),
disambiguated_data: DisambiguatedDefPathData {
data: DefPathData::GlobalMetaData(self.name().as_interned_str()),
data: DefPathData::GlobalMetaData(self.name()),
disambiguator: 0,
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::ty::query::Providers;
use crate::util::nodemap::{NodeMap, FxHashSet};

use errors::FatalError;
use syntax_pos::{Span, DUMMY_SP, symbol::InternedString, MultiSpan};
use syntax_pos::{Span, DUMMY_SP, MultiSpan};
use syntax::source_map::Spanned;
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, AsmDialect};
use syntax::ast::{Attribute, Label, LitKind, StrStyle, FloatTy, IntTy, UintTy};
Expand Down Expand Up @@ -628,9 +628,9 @@ impl Generics {
own_counts
}

pub fn get_named(&self, name: InternedString) -> Option<&GenericParam> {
pub fn get_named(&self, name: Symbol) -> Option<&GenericParam> {
for param in &self.params {
if name == param.name.ident().as_interned_str() {
if name == param.name.ident().name {
return Some(param);
}
}
Expand Down
Loading