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 #65733

Merged
merged 60 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 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
0585475
Avoid ICE when checking `Destination` of `break` inside a closure
estebank Oct 17, 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
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
9220558
Fix an issue with const inference variables sticking around under Cha…
varkor Oct 22, 2019
51c6874
Add regression test for #65675
varkor Oct 22, 2019
fe84809
relax ExactSizeIterator bound on write_bytes: too many iterators don'…
RalfJung Oct 22, 2019
dffc1b3
Apply clippy::useless_let_if_seq suggestion
mati865 Sep 5, 2019
95c06a2
Apply clippy::needless_return suggestions
mati865 Sep 5, 2019
e1aa297
Apply clippy::redundant_pattern_matching suggestion
mati865 Sep 5, 2019
7491468
Apply clippy::while_let_on_iterator suggestions
mati865 Sep 5, 2019
bedbf3b
Apply clippy::single_match suggestion
mati865 Sep 5, 2019
4e8d1b2
Add some documentation
Mark-Simulacrum Oct 22, 2019
eeb549b
Add Cow::is_borrowed and Cow::is_owned
clarfonthey Oct 5, 2019
f69293a
Add `core::macros::matches!( $expr, $pat ) -> bool`
SimonSapin Oct 16, 2019
7472cd4
Move the `matches!` macro to the prelude
SimonSapin Oct 23, 2019
f7ebe19
Add tracking issue for the `matches!` macro
SimonSapin Oct 23, 2019
e76a184
Document guard expressions in `matches!`
SimonSapin Oct 23, 2019
cc7294c
Add regression test for #62579
varkor Oct 23, 2019
12f68e6
Account for const generalisation in combine
varkor Oct 23, 2019
624e34a
Account for const generalisation in nll_relate
varkor Oct 23, 2019
426c6cf
Rollup merge of #64178 - mati865:clippy, r=scottmcm
Centril Oct 23, 2019
4b9fbfb
Rollup merge of #65144 - clarfon:moo, r=sfackler
Centril Oct 23, 2019
7c043e2
Rollup merge of #65193 - Mark-Simulacrum:lockless-lintstore, r=nikoma…
Centril Oct 23, 2019
a1514b4
Rollup merge of #65479 - SimonSapin:matches, r=alexcrichton
Centril Oct 23, 2019
6bb7449
Rollup merge of #65518 - estebank:i-want-to-break-free, r=eddyb
Centril Oct 23, 2019
c192e31
Rollup merge of #65583 - eddyb:more-query-like-cross-crate-tables, r=…
Centril Oct 23, 2019
4a870aa
Rollup merge of #65641 - nnethercote:derive-TokenStream-Encodable-Dec…
Centril Oct 23, 2019
951b8c8
Rollup merge of #65648 - nnethercote:rm-intersect_opt, r=nikomatsakis
Centril Oct 23, 2019
a649b16
Rollup merge of #65657 - nnethercote:rm-InternedString-properly, r=eddyb
Centril Oct 23, 2019
ba9a9eb
Rollup merge of #65691 - GuillaumeGomez:2018-edition-E0659, r=Dylan-DPC
Centril Oct 23, 2019
b2b3579
Rollup merge of #65696 - varkor:nll-chalk-const-generics-issue, r=eddyb
Centril Oct 23, 2019
3cd7a17
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
2 changes: 1 addition & 1 deletion src/liballoc/collections/vec_deque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1817,7 +1817,7 @@ impl<T> VecDeque<T> {
}
}

return elem;
elem
}

/// Splits the `VecDeque` into two at the given index.
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
2 changes: 1 addition & 1 deletion src/liballoc/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl str {
}
}
}
return s;
s
}

/// Converts a [`Box<str>`] into a [`String`] without copying or allocating.
Expand Down
2 changes: 1 addition & 1 deletion src/liballoc/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ impl<T: ?Sized> Clone for Weak<T> {
}
}

return Weak { ptr: self.ptr };
Weak { ptr: self.ptr }
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ impl<T: ?Sized> Pointer for *const T {
if f.alternate() {
f.flags |= 1 << (FlagV1::SignAwareZeroPad as u32);

if let None = f.width {
if f.width.is_none() {
f.width = Some(((mem::size_of::<usize>() * 8) / 4) + 2);
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/libcore/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,33 @@ macro_rules! debug_assert_ne {
($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); })
}

/// Returns whether the given expression matches any of the given patterns.
///
/// Like in a `match` expression, the pattern can be optionally followed by `if`
/// and a guard expression that has access to names bound by the pattern.
///
/// # Examples
///
/// ```
/// #![feature(matches_macro)]
///
/// let foo = 'f';
/// assert!(matches!(foo, 'A'..='Z' | 'a'..='z'));
///
/// let bar = Some(4);
/// assert!(matches!(bar, Some(x) if x > 2));
/// ```
#[macro_export]
#[unstable(feature = "matches_macro", issue = "65721")]
macro_rules! matches {
($expression:expr, $( $pattern:pat )|+ $( if $guard: expr )?) => {
match $expression {
$( $pattern )|+ $( if $guard )? => true,
_ => false
}
}
}

/// Unwraps a result or propagates its error.
///
/// The `?` operator was added to replace `try!` and should be used instead.
Expand Down
9 changes: 4 additions & 5 deletions src/libcore/num/dec2flt/algorithm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,12 @@ pub fn fast_path<T: RawFloat>(integral: &[u8], fractional: &[u8], e: i64) -> Opt
/// > not a bound for the true error, but bounds the difference between the approximation z and
/// > the best possible approximation that uses p bits of significand.)
pub fn bellerophon<T: RawFloat>(f: &Big, e: i16) -> T {
let slop;
if f <= &Big::from_u64(T::MAX_SIG) {
let slop = if f <= &Big::from_u64(T::MAX_SIG) {
// The cases abs(e) < log5(2^N) are in fast_path()
slop = if e >= 0 { 0 } else { 3 };
if e >= 0 { 0 } else { 3 }
} else {
slop = if e >= 0 { 1 } else { 4 };
}
if e >= 0 { 1 } else { 4 }
};
let z = rawfp::big_to_fp(f).mul(&power_of_ten(e)).normalize();
let exp_p_n = 1 << (P - T::SIG_BITS as u32);
let lowbits: i64 = (z.f % exp_p_n) as i64;
Expand Down
5 changes: 2 additions & 3 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -837,9 +837,8 @@ impl<T> Option<T> {
#[inline]
#[stable(feature = "option_entry", since = "1.20.0")]
pub fn get_or_insert_with<F: FnOnce() -> T>(&mut self, f: F) -> &mut T {
match *self {
None => *self = Some(f()),
_ => (),
if let None = *self {
*self = Some(f());
}

match *self {
Expand Down
12 changes: 6 additions & 6 deletions src/libpanic_unwind/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,21 @@ unsafe extern "C" fn rust_eh_personality(version: c_int,
if actions as i32 & uw::_UA_SEARCH_PHASE as i32 != 0 {
match eh_action {
EHAction::None |
EHAction::Cleanup(_) => return uw::_URC_CONTINUE_UNWIND,
EHAction::Catch(_) => return uw::_URC_HANDLER_FOUND,
EHAction::Terminate => return uw::_URC_FATAL_PHASE1_ERROR,
EHAction::Cleanup(_) => uw::_URC_CONTINUE_UNWIND,
EHAction::Catch(_) => uw::_URC_HANDLER_FOUND,
EHAction::Terminate => uw::_URC_FATAL_PHASE1_ERROR,
}
} else {
match eh_action {
EHAction::None => return uw::_URC_CONTINUE_UNWIND,
EHAction::None => uw::_URC_CONTINUE_UNWIND,
EHAction::Cleanup(lpad) |
EHAction::Catch(lpad) => {
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.0, exception_object as uintptr_t);
uw::_Unwind_SetGR(context, UNWIND_DATA_REG.1, 0);
uw::_Unwind_SetIP(context, lpad);
return uw::_URC_INSTALL_CONTEXT;
uw::_URC_INSTALL_CONTEXT
}
EHAction::Terminate => return uw::_URC_FATAL_PHASE2_ERROR,
EHAction::Terminate => uw::_URC_FATAL_PHASE2_ERROR,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/libpanic_unwind/seh64_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub fn payload() -> *mut u8 {

pub unsafe fn cleanup(ptr: *mut u8) -> Box<dyn Any + Send> {
let panic_ctx = Box::from_raw(ptr as *mut PanicData);
return panic_ctx.data;
panic_ctx.data
}

// SEH doesn't support resuming unwinds after calling a landing pad like
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
Loading