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

Closed
wants to merge 25 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
c70eb4b
Automatically expand section if url id point to one of its component
GuillaumeGomez Aug 5, 2018
70cafec
improper_ctypes lint for individual foreign items
VPashkov Aug 6, 2018
e8bb7bf
Account for --remap-path-prefix in save-analysis
Xanewok Aug 6, 2018
b011b09
NetBSD: fix signedess of char
jakllsch Aug 5, 2018
44d32d4
Avoid unnecessary pattern matching against Option and Result
ljedrz Jul 27, 2018
43850e0
Special case error message for thread-local statics.
davidtwco Aug 6, 2018
6608552
Re-enable drop-locations debuginfo tests.
michaelwoerister Aug 7, 2018
4eb52ff
Re-enable a bunch of debuginfo tests.
michaelwoerister Aug 7, 2018
877c469
Avoid increased alignment of TLS segments on Fuchsia
cramertj Aug 7, 2018
f4039af
Suggest comma when missing in macro call
estebank Aug 8, 2018
ffe336d
Fixes #53119.
mikhail-m1 Aug 8, 2018
9876e38
Move SmallVec and ThinVec out of libsyntax
ljedrz Aug 5, 2018
e5f32ef
add comment
nikomatsakis Aug 8, 2018
836b351
Rollup merge of #52773 - ljedrz:unncecessary_patterns, r=nikomatsakis
cramertj Aug 8, 2018
2b41b67
Rollup merge of #53085 - ljedrz:cleanup_syntax_structures, r=Mark-Sim…
cramertj Aug 8, 2018
f852b80
Rollup merge of #53094 - GuillaumeGomez:automatic-expand, r=nrc
cramertj Aug 8, 2018
29c2072
Rollup merge of #53100 - VPashkov:issue-52456-improper_ctypes, r=eddyb
cramertj Aug 8, 2018
e9a4e44
Rollup merge of #53110 - Xanewok:save-analysis-remap-path, r=nrc
cramertj Aug 8, 2018
24e6963
Rollup merge of #53116 - jakllsch:netbsd-unsigned-char, r=alexcrichton
cramertj Aug 8, 2018
3bfccd7
Rollup merge of #53131 - davidtwco:issue-52663-thread-local-static, r…
cramertj Aug 8, 2018
d3c2ab4
Rollup merge of #53152 - michaelwoerister:reenable-drop-location-debu…
cramertj Aug 8, 2018
5cebf8c
Rollup merge of #53154 - michaelwoerister:reenable-some-debuginfo-tes…
cramertj Aug 8, 2018
8d49a53
Rollup merge of #53180 - cramertj:tls-align, r=alexcrichton
cramertj Aug 8, 2018
327753d
Rollup merge of #53183 - estebank:println-comma, r=oli-obk
cramertj Aug 8, 2018
888c158
Rollup merge of #53186 - mikhail-m1:master, r=nikomatsakis
cramertj Aug 8, 2018
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 src/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2048,6 +2048,7 @@ version = "0.0.0"
dependencies = [
"log 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc 0.0.0",
"rustc_data_structures 0.0.0",
"rustc_errors 0.0.0",
"rustc_target 0.0.0",
"syntax 0.0.0",
Expand Down
25 changes: 13 additions & 12 deletions src/librustc/hir/lowering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ use lint::builtin::{self, PARENTHESIZED_PARAMS_IN_TYPES_AND_MODULES,
ELIDED_LIFETIMES_IN_PATHS};
use middle::cstore::CrateStore;
use rustc_data_structures::indexed_vec::IndexVec;
use rustc_data_structures::small_vec::OneVector;
use rustc_data_structures::thin_vec::ThinVec;
use session::Session;
use util::common::FN_OUTPUT_NAME;
use util::nodemap::{DefIdMap, NodeMap};
Expand All @@ -71,7 +73,6 @@ use syntax::std_inject;
use syntax::symbol::{keywords, Symbol};
use syntax::tokenstream::{Delimited, TokenStream, TokenTree};
use syntax::parse::token::Token;
use syntax::util::small_vector::SmallVector;
use syntax::visit::{self, Visitor};
use syntax_pos::{Span, MultiSpan};

Expand Down Expand Up @@ -3136,12 +3137,12 @@ impl<'a> LoweringContext<'a> {
&mut self,
decl: &FnDecl,
header: &FnHeader,
ids: &mut SmallVector<hir::ItemId>,
ids: &mut OneVector<hir::ItemId>,
) {
if let Some(id) = header.asyncness.opt_return_id() {
ids.push(hir::ItemId { id });
}
struct IdVisitor<'a> { ids: &'a mut SmallVector<hir::ItemId> }
struct IdVisitor<'a> { ids: &'a mut OneVector<hir::ItemId> }
impl<'a, 'b> Visitor<'a> for IdVisitor<'b> {
fn visit_ty(&mut self, ty: &'a Ty) {
match ty.node {
Expand Down Expand Up @@ -3174,36 +3175,36 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_item_id(&mut self, i: &Item) -> SmallVector<hir::ItemId> {
fn lower_item_id(&mut self, i: &Item) -> OneVector<hir::ItemId> {
match i.node {
ItemKind::Use(ref use_tree) => {
let mut vec = SmallVector::one(hir::ItemId { id: i.id });
let mut vec = OneVector::one(hir::ItemId { id: i.id });
self.lower_item_id_use_tree(use_tree, i.id, &mut vec);
vec
}
ItemKind::MacroDef(..) => SmallVector::new(),
ItemKind::MacroDef(..) => OneVector::new(),
ItemKind::Fn(ref decl, ref header, ..) => {
let mut ids = SmallVector::one(hir::ItemId { id: i.id });
let mut ids = OneVector::one(hir::ItemId { id: i.id });
self.lower_impl_trait_ids(decl, header, &mut ids);
ids
},
ItemKind::Impl(.., None, _, ref items) => {
let mut ids = SmallVector::one(hir::ItemId { id: i.id });
let mut ids = OneVector::one(hir::ItemId { id: i.id });
for item in items {
if let ImplItemKind::Method(ref sig, _) = item.node {
self.lower_impl_trait_ids(&sig.decl, &sig.header, &mut ids);
}
}
ids
},
_ => SmallVector::one(hir::ItemId { id: i.id }),
_ => OneVector::one(hir::ItemId { id: i.id }),
}
}

fn lower_item_id_use_tree(&mut self,
tree: &UseTree,
base_id: NodeId,
vec: &mut SmallVector<hir::ItemId>)
vec: &mut OneVector<hir::ItemId>)
{
match tree.kind {
UseTreeKind::Nested(ref nested_vec) => for &(ref nested, id) in nested_vec {
Expand Down Expand Up @@ -4295,8 +4296,8 @@ impl<'a> LoweringContext<'a> {
}
}

fn lower_stmt(&mut self, s: &Stmt) -> SmallVector<hir::Stmt> {
SmallVector::one(match s.node {
fn lower_stmt(&mut self, s: &Stmt) -> OneVector<hir::Stmt> {
OneVector::one(match s.node {
StmtKind::Local(ref l) => Spanned {
node: hir::StmtKind::Decl(
P(Spanned {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ use syntax::ext::hygiene::SyntaxContext;
use syntax::ptr::P;
use syntax::symbol::{Symbol, keywords};
use syntax::tokenstream::TokenStream;
use syntax::util::ThinVec;
use syntax::util::parser::ExprPrecedence;
use ty::AdtKind;
use ty::query::Providers;

use rustc_data_structures::indexed_vec;
use rustc_data_structures::sync::{ParallelIterator, par_iter, Send, Sync, scope};
use rustc_data_structures::thin_vec::ThinVec;

use serialize::{self, Encoder, Encodable, Decoder, Decodable};
use std::collections::BTreeMap;
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/traits/auto_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,10 +681,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
}
}
&ty::Predicate::RegionOutlives(ref binder) => {
if let Err(_) = select
.infcx()
.region_outlives_predicate(&dummy_cause, binder)
{
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
// Eventually I'll need to implement param-env-aware
// `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
let param_env = ty::ParamEnv::empty();
if let Ok(_) = self.can_sub(param_env, error, implication) {
if self.can_sub(param_env, error, implication).is_ok() {
debug!("error_implies: {:?} -> {:?} -> {:?}", cond, error, implication);
return true
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/traits/query/outlives_bounds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
// variables. Process these constraints.
let mut fulfill_cx = FulfillmentContext::new();
fulfill_cx.register_predicate_obligations(self, result.obligations);
if let Err(_) = fulfill_cx.select_all_or_error(self) {
if fulfill_cx.select_all_or_error(self).is_err() {
self.tcx.sess.delay_span_bug(
span,
"implied_outlives_bounds failed to solve obligations from instantiation"
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/traits/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,8 +1587,8 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
-> bool
{
assert!(!skol_trait_ref.has_escaping_regions());
if let Err(_) = self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound) {
if self.infcx.at(&obligation.cause, obligation.param_env)
.sup(ty::Binder::dummy(skol_trait_ref), trait_bound).is_err() {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn resolve_associated_item<'a, 'tcx>(
})
}
traits::VtableBuiltin(..) => {
if let Some(_) = tcx.lang_items().clone_trait() {
if tcx.lang_items().clone_trait().is_some() {
Some(Instance {
def: ty::InstanceDef::CloneShim(def_id, trait_ref.self_ty()),
substs: rcvr_substs
Expand Down
1 change: 1 addition & 0 deletions src/librustc_allocator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ test = false

[dependencies]
rustc = { path = "../librustc" }
rustc_data_structures = { path = "../librustc_data_structures" }
rustc_errors = { path = "../librustc_errors" }
rustc_target = { path = "../librustc_target" }
syntax = { path = "../libsyntax" }
Expand Down
14 changes: 7 additions & 7 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

use rustc::middle::allocator::AllocatorKind;
use rustc_data_structures::small_vec::OneVector;
use rustc_errors;
use syntax::{
ast::{
Expand All @@ -28,8 +29,7 @@ use syntax::{
fold::{self, Folder},
parse::ParseSess,
ptr::P,
symbol::Symbol,
util::small_vector::SmallVector,
symbol::Symbol
};
use syntax_pos::Span;

Expand Down Expand Up @@ -65,7 +65,7 @@ struct ExpandAllocatorDirectives<'a> {
}

impl<'a> Folder for ExpandAllocatorDirectives<'a> {
fn fold_item(&mut self, item: P<Item>) -> SmallVector<P<Item>> {
fn fold_item(&mut self, item: P<Item>) -> OneVector<P<Item>> {
debug!("in submodule {}", self.in_submod);

let name = if attr::contains_name(&item.attrs, "global_allocator") {
Expand All @@ -78,20 +78,20 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
_ => {
self.handler
.span_err(item.span, "allocators must be statics");
return SmallVector::one(item);
return OneVector::one(item);
}
}

if self.in_submod > 0 {
self.handler
.span_err(item.span, "`global_allocator` cannot be used in submodules");
return SmallVector::one(item);
return OneVector::one(item);
}

if self.found {
self.handler
.span_err(item.span, "cannot define more than one #[global_allocator]");
return SmallVector::one(item);
return OneVector::one(item);
}
self.found = true;

Expand Down Expand Up @@ -152,7 +152,7 @@ impl<'a> Folder for ExpandAllocatorDirectives<'a> {
let module = f.cx.monotonic_expander().fold_item(module).pop().unwrap();

// Return the item and new submodule
let mut ret = SmallVector::with_capacity(2);
let mut ret = OneVector::with_capacity(2);
ret.push(item);
ret.push(module);

Expand Down
1 change: 1 addition & 0 deletions src/librustc_allocator/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#[macro_use] extern crate log;
extern crate rustc;
extern crate rustc_data_structures;
extern crate rustc_errors;
extern crate rustc_target;
extern crate syntax;
Expand Down
10 changes: 8 additions & 2 deletions src/librustc_codegen_llvm/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ pub fn codegen_static<'a, 'tcx>(
if attrs.flags.contains(CodegenFnAttrFlags::THREAD_LOCAL) {
llvm::set_thread_local_mode(g, cx.tls_model);

// Do not allow LLVM to change the alignment of a TLS on macOS.
// Do not allow LLVM to change the alignment of a TLS on macOS and Fuchsia.
//
// By default a global's alignment can be freely increased.
// This allows LLVM to generate more performant instructions
Expand All @@ -361,6 +361,10 @@ pub fn codegen_static<'a, 'tcx>(
// respect any alignment given on the TLS (radar 24221680).
// This will violate the alignment assumption, and causing segfault at runtime.
//
// Fuchsia's libc currently does not support greater than 16-byte alignment
// of TLS segments, so this hack is also enabled temporarily for Fuchsia targets
// until libc is fixed.
//
// This bug is very easy to trigger. In `println!` and `panic!`,
// the `LOCAL_STDOUT`/`LOCAL_STDERR` handles are stored in a TLS,
// which the values would be `mem::replace`d on initialization.
Expand All @@ -380,7 +384,9 @@ pub fn codegen_static<'a, 'tcx>(
// will use load-unaligned instructions instead, and thus avoiding the crash.
//
// We could remove this hack whenever we decide to drop macOS 10.10 support.
if cx.tcx.sess.target.target.options.is_like_osx {
if cx.tcx.sess.target.target.options.is_like_osx ||
(cx.tcx.sess.target.target.target_os == "fuchsia")
{
let sect_name = if alloc.bytes.iter().all(|b| *b == 0) {
CStr::from_bytes_with_nul_unchecked(b"__DATA,__thread_bss\0")
} else {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_data_structures/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub mod sorted_map;
pub mod stable_hasher;
pub mod sync;
pub mod tiny_list;
pub mod thin_vec;
pub mod transitive_relation;
pub mod tuple_slice;
pub use ena::unify;
Expand Down
65 changes: 65 additions & 0 deletions src/librustc_data_structures/small_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ use array_vec::Array;

pub struct SmallVec<A: Array>(AccumulateVec<A>);

pub type OneVector<T> = SmallVec<[T; 1]>;

impl<A> Clone for SmallVec<A>
where A: Array,
A::Element: Clone {
Expand Down Expand Up @@ -222,6 +224,69 @@ mod tests {

use super::*;

#[test]
fn test_len() {
let v: OneVector<isize> = OneVector::new();
assert_eq!(0, v.len());

assert_eq!(1, OneVector::one(1).len());
assert_eq!(5, OneVector::many(vec![1, 2, 3, 4, 5]).len());
}

#[test]
fn test_push_get() {
let mut v = OneVector::new();
v.push(1);
assert_eq!(1, v.len());
assert_eq!(1, v[0]);
v.push(2);
assert_eq!(2, v.len());
assert_eq!(2, v[1]);
v.push(3);
assert_eq!(3, v.len());
assert_eq!(3, v[2]);
}

#[test]
fn test_from_iter() {
let v: OneVector<isize> = (vec![1, 2, 3]).into_iter().collect();
assert_eq!(3, v.len());
assert_eq!(1, v[0]);
assert_eq!(2, v[1]);
assert_eq!(3, v[2]);
}

#[test]
fn test_move_iter() {
let v = OneVector::new();
let v: Vec<isize> = v.into_iter().collect();
assert_eq!(v, Vec::new());

let v = OneVector::one(1);
assert_eq!(v.into_iter().collect::<Vec<_>>(), [1]);

let v = OneVector::many(vec![1, 2, 3]);
assert_eq!(v.into_iter().collect::<Vec<_>>(), [1, 2, 3]);
}

#[test]
#[should_panic]
fn test_expect_one_zero() {
let _: isize = OneVector::new().expect_one("");
}

#[test]
#[should_panic]
fn test_expect_one_many() {
OneVector::many(vec![1, 2]).expect_one("");
}

#[test]
fn test_expect_one_one() {
assert_eq!(1, OneVector::one(1).expect_one(""));
assert_eq!(1, OneVector::many(vec![1]).expect_one(""));
}

#[bench]
fn fill_small_vec_1_10_with_cap(b: &mut Bencher) {
b.iter(|| {
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_driver/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ use rustc::session::Session;
use rustc::session::config::{Input, OutputFilenames};
use rustc_borrowck as borrowck;
use rustc_borrowck::graphviz as borrowck_dot;
use rustc_data_structures::small_vec::OneVector;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_metadata::cstore::CStore;

use rustc_mir::util::{write_mir_pretty, write_mir_graphviz};
Expand All @@ -33,8 +35,6 @@ use syntax::fold::{self, Folder};
use syntax::print::{pprust};
use syntax::print::pprust::PrintState;
use syntax::ptr::P;
use syntax::util::ThinVec;
use syntax::util::small_vector::SmallVector;
use syntax_pos::{self, FileName};

use graphviz as dot;
Expand Down Expand Up @@ -727,7 +727,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
self.run(is_const, |s| fold::noop_fold_item_kind(i, s))
}

fn fold_trait_item(&mut self, i: ast::TraitItem) -> SmallVector<ast::TraitItem> {
fn fold_trait_item(&mut self, i: ast::TraitItem) -> OneVector<ast::TraitItem> {
let is_const = match i.node {
ast::TraitItemKind::Const(..) => true,
ast::TraitItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
Expand All @@ -737,7 +737,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
self.run(is_const, |s| fold::noop_fold_trait_item(i, s))
}

fn fold_impl_item(&mut self, i: ast::ImplItem) -> SmallVector<ast::ImplItem> {
fn fold_impl_item(&mut self, i: ast::ImplItem) -> OneVector<ast::ImplItem> {
let is_const = match i.node {
ast::ImplItemKind::Const(..) => true,
ast::ImplItemKind::Method(ast::MethodSig { ref decl, ref header, .. }, _) =>
Expand Down Expand Up @@ -785,7 +785,7 @@ impl<'a> fold::Folder for ReplaceBodyWithLoop<'a> {
node: ast::ExprKind::Loop(P(empty_block), None),
id: self.sess.next_node_id(),
span: syntax_pos::DUMMY_SP,
attrs: ast::ThinVec::new(),
attrs: ThinVec::new(),
});

let loop_stmt = ast::Stmt {
Expand Down
Loading