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 10 pull requests #70257

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
6f6fe38
parse/lexer: support `StringReader::retokenize` called on external fi…
eddyb Mar 20, 2020
4d30b92
recover on `for<'a> |...| body` closures.
Centril Mar 21, 2020
a9c2378
fix type of const params in associated types.
lcnr Mar 21, 2020
e991df8
Only display definition on typo
LeSeulArtichaut Mar 21, 2020
cb7a2c1
Bless tests
LeSeulArtichaut Mar 21, 2020
54e103b
don't convert results to options just for matching (clippy::if_let_so…
matthiaskrgr Mar 21, 2020
1dcbdbd
use let instead of match for matches with single bindings (clippy::ma…
matthiaskrgr Mar 21, 2020
5566a1c
remove redundant returns (clippy::needless_return)
matthiaskrgr Mar 21, 2020
3b4c2f6
don't redundantly repeat field names (clippy::redundant_field_names)
matthiaskrgr Mar 21, 2020
c8140a8
Return NonZeroU64 from ThreadId::as_u64.
Mar 21, 2020
a6692b7
clarify when we pass () to functions (clippy::unit_arg)
matthiaskrgr Mar 21, 2020
47e9775
make some let-if-bindings more idiomatic (clippy::useless_let_if_seq)
matthiaskrgr Mar 21, 2020
e45fdcf
remove unused unit values (clippy::unused_unit)
matthiaskrgr Mar 21, 2020
c2fd465
rustc_expand::base: nix panictry! uses
Centril Mar 17, 2020
2a9cd1d
nix panictry! in ParserAnyMacro::make
Centril Mar 17, 2020
e6743b0
nix remaining rustc_expand::panictry! uses.
Centril Mar 17, 2020
5f3d63e
generic_extension: defatalize Error case
Centril Mar 17, 2020
20a5c4a
defatalize BangProcMacro::expand
Centril Mar 17, 2020
1b2ef28
defatalize AttrProcMacro::expand
Centril Mar 17, 2020
daa3056
defatalize ProcMacroDerive::expand
Centril Mar 17, 2020
ba4cf18
remove ExtCxt::struct_span_warn
Centril Mar 17, 2020
60d7608
mbe::transcribe: defatalize errors.
Centril Mar 17, 2020
5fb479f
defatalize `compile_declarative_macro`
Centril Mar 17, 2020
3ff9376
expand: nix unused method
Centril Mar 17, 2020
615a5f0
defatalize get_test_runner
Centril Mar 17, 2020
f41ae8e
defatalize expand_test_or_bench
Centril Mar 17, 2020
aa9a70c
expand: add recovery for parse_nt
Centril Mar 17, 2020
7c5dcc9
expand: address review comments
Centril Mar 18, 2020
1110690
fix rebase fallout
Centril Mar 20, 2020
4a67a1b
fix rebase fallout due to #69497.
Centril Mar 21, 2020
c746d93
Remove wrong entry from RELEASES.md
jplatte Mar 21, 2020
3f42104
Remove another wrong entry from RELEASES.md
jplatte Mar 21, 2020
3599fd3
summarize if-else-code with identical blocks (clippy::if_same_then_else)
matthiaskrgr Mar 21, 2020
74d68ea
don't create variable bindings just to return the bound value immedia…
matthiaskrgr Mar 21, 2020
9f802cd
Rollup merge of #70074 - Centril:unpanictry, r=petrochenkov
Centril Mar 22, 2020
34ef6d0
Rollup merge of #70172 - eddyb:retokenize-external-src, r=petrochenkov
Centril Mar 22, 2020
ddd59bc
Rollup merge of #70209 - Centril:recover-quant-closure, r=petrochenkov
Centril Mar 22, 2020
520dbfe
Rollup merge of #70223 - lcnr:issue70167, r=eddyb
Centril Mar 22, 2020
2d25f71
Rollup merge of #70227 - LeSeulArtichaut:typo-def, r=Centril
Centril Mar 22, 2020
e90a648
Rollup merge of #70229 - matthiaskrgr:cl3ppy, r=Mark-Simulacrum
Centril Mar 22, 2020
b465c20
Rollup merge of #70240 - brain0:thread_id, r=Mark-Simulacrum
Centril Mar 22, 2020
aade079
Rollup merge of #70250 - jplatte:patch-1, r=Centril
Centril Mar 22, 2020
8406150
Rollup merge of #70253 - jplatte:patch-2, r=Mark-Simulacrum
Centril Mar 22, 2020
688d655
Rollup merge of #70254 - matthiaskrgr:cl4ppy, r=Centril
Centril Mar 22, 2020
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
3 changes: 0 additions & 3 deletions RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4838,7 +4838,6 @@ Version 1.11.0 (2016-08-18)
Language
--------

* [`cfg_attr` works on `path` attributes](https://github.com/rust-lang/rust/pull/34546)
* [Support nested `cfg_attr` attributes](https://github.com/rust-lang/rust/pull/34216)
* [Allow statement-generating braced macro invocations at the end of blocks](https://github.com/rust-lang/rust/pull/34436)
* [Macros can be expanded inside of trait definitions](https://github.com/rust-lang/rust/pull/34213)
Expand Down Expand Up @@ -4957,8 +4956,6 @@ Version 1.10.0 (2016-07-07)
Language
--------

* [Allow `concat_idents!` in type positions as well as in expression
positions](https://github.com/rust-lang/rust/pull/33735).
* [`Copy` types are required to have a trivial implementation of `Clone`](https://github.com/rust-lang/rust/pull/33420).
[RFC 1521](https://github.com/rust-lang/rfcs/blob/master/text/1521-copy-clone-semantics.md).
* [Single-variant enums support the `#[repr(..)]` attribute](https://github.com/rust-lang/rust/pull/33355).
Expand Down
3 changes: 1 addition & 2 deletions src/liballoc/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ mod hack {
unsafe {
let len = b.len();
let b = Box::into_raw(b);
let xs = Vec::from_raw_parts(b as *mut T, len, len);
xs
Vec::from_raw_parts(b as *mut T, len, len)
}
}

Expand Down
4 changes: 1 addition & 3 deletions src/librustc/hir/map/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1044,9 +1044,7 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe
collector.finalize_and_compute_crate_hash(crate_disambiguator, &*tcx.cstore, cmdline_args)
};

let map = tcx.arena.alloc(IndexedHir { crate_hash, map });

map
tcx.arena.alloc(IndexedHir { crate_hash, map })
}

/// Identical to the `PpAnn` implementation for `hir::Crate`,
Expand Down
54 changes: 25 additions & 29 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,8 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
// Field 5 would be the first element, so memory_index is i:
// Note: if we didn't optimize, it's already right.

let memory_index;
if optimize {
memory_index = invert_mapping(&inverse_memory_index);
} else {
memory_index = inverse_memory_index;
}
let memory_index =
if optimize { invert_mapping(&inverse_memory_index) } else { inverse_memory_index };

let size = min_size.align_to(align.abi);
let mut abi = Abi::Aggregate { sized };
Expand Down Expand Up @@ -944,33 +940,33 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
let offset = st[i].fields.offset(field_index) + niche.offset;
let size = st[i].size;

let mut abi = match st[i].abi {
Abi::Scalar(_) => Abi::Scalar(niche_scalar.clone()),
Abi::ScalarPair(ref first, ref second) => {
// We need to use scalar_unit to reset the
// valid range to the maximal one for that
// primitive, because only the niche is
// guaranteed to be initialised, not the
// other primitive.
if offset.bytes() == 0 {
Abi::ScalarPair(
niche_scalar.clone(),
scalar_unit(second.value),
)
} else {
Abi::ScalarPair(
scalar_unit(first.value),
niche_scalar.clone(),
)
let abi = if st.iter().all(|v| v.abi.is_uninhabited()) {
Abi::Uninhabited
} else {
match st[i].abi {
Abi::Scalar(_) => Abi::Scalar(niche_scalar.clone()),
Abi::ScalarPair(ref first, ref second) => {
// We need to use scalar_unit to reset the
// valid range to the maximal one for that
// primitive, because only the niche is
// guaranteed to be initialised, not the
// other primitive.
if offset.bytes() == 0 {
Abi::ScalarPair(
niche_scalar.clone(),
scalar_unit(second.value),
)
} else {
Abi::ScalarPair(
scalar_unit(first.value),
niche_scalar.clone(),
)
}
}
_ => Abi::Aggregate { sized: true },
}
_ => Abi::Aggregate { sized: true },
};

if st.iter().all(|v| v.abi.is_uninhabited()) {
abi = Abi::Uninhabited;
}

let largest_niche =
Niche::from_scalar(dl, offset, niche_scalar.clone());

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ impl<'tcx> TyCtxt<'tcx> {
/// side-effects -- e.g., in order to report errors for erroneous programs.
///
/// Note: The optimization is only available during incr. comp.
pub(super) fn ensure_query<Q: QueryDescription<'tcx> + 'tcx>(self, key: Q::Key) -> () {
pub(super) fn ensure_query<Q: QueryDescription<'tcx> + 'tcx>(self, key: Q::Key) {
if Q::EVAL_ALWAYS {
let _ = self.get_query::<Q>(DUMMY_SP, key);
return;
Expand Down
9 changes: 7 additions & 2 deletions src/librustc_builtin_macros/cmdline_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use rustc_ast::ast::{self, AttrItem, AttrStyle};
use rustc_ast::attr::mk_attr;
use rustc_ast::token;
use rustc_expand::panictry;
use rustc_session::parse::ParseSess;
use rustc_span::FileName;

Expand All @@ -16,7 +15,13 @@ pub fn inject(mut krate: ast::Crate, parse_sess: &ParseSess, attrs: &[String]) -
);

let start_span = parser.token.span;
let AttrItem { path, args } = panictry!(parser.parse_attr_item());
let AttrItem { path, args } = match parser.parse_attr_item() {
Ok(ai) => ai,
Err(mut err) => {
err.emit();
continue;
}
};
let end_span = parser.token.span;
if parser.token != token::Eof {
parse_sess.span_diagnostic.span_err(start_span.to(end_span), "invalid crate attribute");
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_builtin_macros/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,9 @@ impl<'a> MethodDef<'a> {
self_: field,
other: other_fields
.iter_mut()
.map(|l| match l.next().unwrap() {
(.., ex, _) => ex,
.map(|l| {
let (.., ex, _) = l.next().unwrap();
ex
})
.collect(),
attrs,
Expand Down
24 changes: 11 additions & 13 deletions src/librustc_builtin_macros/source_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use rustc_ast::tokenstream::TokenStream;
use rustc_ast_pretty::pprust;
use rustc_expand::base::{self, *};
use rustc_expand::module::DirectoryOwnership;
use rustc_expand::panictry;
use rustc_parse::{self, new_sub_parser_from_file, parser::Parser};
use rustc_session::lint::builtin::INCOMPLETE_INCLUDE;
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -126,7 +125,7 @@ pub fn expand_include<'cx>(
}
impl<'a> base::MacResult for ExpandResult<'a> {
fn make_expr(mut self: Box<ExpandResult<'a>>) -> Option<P<ast::Expr>> {
let r = panictry!(self.p.parse_expr());
let r = base::parse_expr(&mut self.p)?;
if self.p.token != token::Eof {
self.p.sess.buffer_lint(
&INCOMPLETE_INCLUDE,
Expand All @@ -141,18 +140,17 @@ pub fn expand_include<'cx>(
fn make_items(mut self: Box<ExpandResult<'a>>) -> Option<SmallVec<[P<ast::Item>; 1]>> {
let mut ret = SmallVec::new();
while self.p.token != token::Eof {
match panictry!(self.p.parse_item()) {
Some(item) => ret.push(item),
None => {
match self.p.parse_item() {
Err(mut err) => {
err.emit();
break;
}
Ok(Some(item)) => ret.push(item),
Ok(None) => {
let token = pprust::token_to_string(&self.p.token);
self.p
.sess
.span_diagnostic
.span_fatal(
self.p.token.span,
&format!("expected item, found `{}`", token),
)
.raise();
let msg = format!("expected item, found `{}`", token);
self.p.struct_span_err(self.p.token.span, &msg).emit();
break;
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_builtin_macros/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ pub fn expand_test_or_bench(
return vec![];
}

let item = if let Annotatable::Item(i) = item {
i
} else {
cx.parse_sess
.span_diagnostic
.span_fatal(
item.span(),
let item = match item {
Annotatable::Item(i) => i,
other => {
cx.struct_span_err(
other.span(),
"`#[test]` attribute is only allowed on non associated functions",
)
.raise();
.emit();
return vec![other];
}
};

if let ast::ItemKind::MacCall(_) = item.kind {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc_builtin_macros/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,14 @@ fn is_test_case(i: &ast::Item) -> bool {

fn get_test_runner(sd: &rustc_errors::Handler, krate: &ast::Crate) -> Option<ast::Path> {
let test_attr = attr::find_by_name(&krate.attrs, sym::test_runner)?;
test_attr.meta_item_list().map(|meta_list| {
if meta_list.len() != 1 {
sd.span_fatal(test_attr.span, "`#![test_runner(..)]` accepts exactly 1 argument")
.raise()
}
match meta_list[0].meta_item() {
Some(meta_item) if meta_item.is_word() => meta_item.path.clone(),
_ => sd.span_fatal(test_attr.span, "`test_runner` argument must be a path").raise(),
}
})
let meta_list = test_attr.meta_item_list()?;
let span = test_attr.span;
match &*meta_list {
[single] => match single.meta_item() {
Some(meta_item) if meta_item.is_word() => return Some(meta_item.path.clone()),
_ => sd.struct_span_err(span, "`test_runner` argument must be a path").emit(),
},
_ => sd.struct_span_err(span, "`#![test_runner(..)]` accepts exactly 1 argument").emit(),
}
None
}
4 changes: 1 addition & 3 deletions src/librustc_codegen_ssa/back/rpath.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,7 @@ fn get_rpaths(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec<String> {
rpaths.extend_from_slice(&fallback_rpaths);

// Remove duplicates
let rpaths = minimize_rpaths(&rpaths);

rpaths
minimize_rpaths(&rpaths)
}

fn get_rpaths_relative_to_output(config: &mut RPathConfig<'_>, libs: &[PathBuf]) -> Vec<String> {
Expand Down
6 changes: 2 additions & 4 deletions src/librustc_codegen_ssa/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ fn generate_lto_work<B: ExtraBackendMethods>(
B::run_thin_lto(cgcx, needs_thin_lto, import_only_modules).unwrap_or_else(|e| e.raise())
};

let result = lto_modules
lto_modules
.into_iter()
.map(|module| {
let cost = module.cost();
Expand All @@ -303,9 +303,7 @@ fn generate_lto_work<B: ExtraBackendMethods>(
0,
)
}))
.collect();

result
.collect()
}

pub struct CompiledModules {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_data_structures/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl SelfProfilerRef {
) {
drop(self.exec(event_filter, |profiler| {
let event_id = StringId::new_virtual(query_invocation_id.0);
let thread_id = std::thread::current().id().as_u64() as u32;
let thread_id = std::thread::current().id().as_u64().get() as u32;

profiler.profiler.record_instant_event(
event_kind(profiler),
Expand Down Expand Up @@ -522,7 +522,7 @@ impl<'a> TimingGuard<'a> {
event_kind: StringId,
event_id: EventId,
) -> TimingGuard<'a> {
let thread_id = std::thread::current().id().as_u64() as u32;
let thread_id = std::thread::current().id().as_u64().get() as u32;
let raw_profiler = &profiler.profiler;
let timing_guard =
raw_profiler.start_recording_interval_event(event_kind, event_id, thread_id);
Expand Down
Loading