diff options
| author | bors <bors@rust-lang.org> | 2022-08-10 06:09:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-10 06:09:10 +0000 |
| commit | 1603a70f82240ba2d27f72f964e36614d7620ad3 (patch) | |
| tree | 92fec792de17c4f5ae761d3b9254ad1fa2a54d68 /compiler | |
| parent | 0459d2fa736a556332ea9613ad0edf073107cb40 (diff) | |
| parent | f6ce6aba6e464644d9bb8cb21e30f9d09078df61 (diff) | |
| download | rust-1603a70f82240ba2d27f72f964e36614d7620ad3.tar.gz rust-1603a70f82240ba2d27f72f964e36614d7620ad3.zip | |
Auto merge of #100356 - matthiaskrgr:rollup-he0vkjc, r=matthiaskrgr
Rollup of 8 pull requests Successful merges: - #99573 (Stabilize backtrace) - #100069 (Add error if link_ordinal used with unsupported link kind) - #100086 (Add more `// unit-test`s to MIR opt tests) - #100332 (Rename integer log* methods to ilog*) - #100334 (Suggest a missing semicolon before an array) - #100340 (Iterate generics_def_id_map in reverse order to fix P-critical issue) - #100345 (docs: remove repetition in `is_numeric` function docs) - #100352 (Update cargo) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_ast_lowering/src/lib.rs | 15 | ||||
| -rw-r--r-- | compiler/rustc_errors/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/native_libs.rs | 26 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/lib.rs | 1 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 42 |
5 files changed, 81 insertions, 4 deletions
diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 0562f7b88a3..38d30d0ffde 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -220,7 +220,20 @@ impl ResolverAstLoweringExt for ResolverAstLowering { } fn get_remapped_def_id(&self, mut local_def_id: LocalDefId) -> LocalDefId { - for map in &self.generics_def_id_map { + // `generics_def_id_map` is a stack of mappings. As we go deeper in impl traits nesting we + // push new mappings so we need to try first the latest mappings, hence `iter().rev()`. + // + // Consider: + // + // `fn test<'a, 'b>() -> impl Trait<&'a u8, Ty = impl Sized + 'b> {}` + // + // We would end with a generics_def_id_map like: + // + // `[[fn#'b -> impl_trait#'b], [fn#'b -> impl_sized#'b]]` + // + // for the opaque type generated on `impl Sized + 'b`, We want the result to be: + // impl_sized#'b, so iterating forward is the wrong thing to do. + for map in self.generics_def_id_map.iter().rev() { if let Some(r) = map.get(&local_def_id) { debug!("def_id_remapper: remapping from `{local_def_id:?}` to `{r:?}`"); local_def_id = *r; diff --git a/compiler/rustc_errors/src/lib.rs b/compiler/rustc_errors/src/lib.rs index 2d3155a70ed..15c1858023d 100644 --- a/compiler/rustc_errors/src/lib.rs +++ b/compiler/rustc_errors/src/lib.rs @@ -4,7 +4,6 @@ #![doc(html_root_url = "https://doc.rust-lang.org/nightly/nightly-rustc/")] #![feature(drain_filter)] -#![feature(backtrace)] #![feature(if_let_guard)] #![cfg_attr(bootstrap, feature(let_chains))] #![feature(let_else)] diff --git a/compiler/rustc_metadata/src/native_libs.rs b/compiler/rustc_metadata/src/native_libs.rs index 9f6079ecba4..c5e39507d7e 100644 --- a/compiler/rustc_metadata/src/native_libs.rs +++ b/compiler/rustc_metadata/src/native_libs.rs @@ -328,7 +328,31 @@ impl<'tcx> Collector<'tcx> { .map(|child_item| self.build_dll_import(abi, child_item)) .collect() } - _ => Vec::new(), + _ => { + for child_item in foreign_mod_items { + if self.tcx.def_kind(child_item.id.def_id).has_codegen_attrs() + && self + .tcx + .codegen_fn_attrs(child_item.id.def_id) + .link_ordinal + .is_some() + { + let link_ordinal_attr = self + .tcx + .hir() + .attrs(self.tcx.hir().local_def_id_to_hir_id(child_item.id.def_id)) + .iter() + .find(|a| a.has_name(sym::link_ordinal)) + .unwrap(); + sess.span_err( + link_ordinal_attr.span, + "`#[link_ordinal]` is only supported if link kind is `raw-dylib`", + ); + } + } + + Vec::new() + } }; self.libs.push(NativeLib { name: name.map(|(name, _)| name), diff --git a/compiler/rustc_middle/src/lib.rs b/compiler/rustc_middle/src/lib.rs index 45c6468bc24..4e1254efd17 100644 --- a/compiler/rustc_middle/src/lib.rs +++ b/compiler/rustc_middle/src/lib.rs @@ -26,7 +26,6 @@ #![feature(allocator_api)] #![feature(array_windows)] #![feature(assert_matches)] -#![feature(backtrace)] #![feature(box_patterns)] #![feature(core_intrinsics)] #![feature(discriminant_kind)] diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e473f4d30cf..b8bd960a5b3 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1258,8 +1258,11 @@ impl<'a> Parser<'a> { /// Parse an indexing expression `expr[...]`. fn parse_index_expr(&mut self, lo: Span, base: P<Expr>) -> PResult<'a, P<Expr>> { + let prev_span = self.prev_token.span; + let open_delim_span = self.token.span; self.bump(); // `[` let index = self.parse_expr()?; + self.suggest_missing_semicolon_before_array(prev_span, open_delim_span)?; self.expect(&token::CloseDelim(Delimiter::Bracket))?; Ok(self.mk_expr(lo.to(self.prev_token.span), self.mk_index(base, index), AttrVec::new())) } @@ -2056,6 +2059,45 @@ impl<'a> Parser<'a> { } } + fn suggest_missing_semicolon_before_array( + &self, + prev_span: Span, + open_delim_span: Span, + ) -> PResult<'a, ()> { + if self.token.kind == token::Comma { + let mut snapshot = self.create_snapshot_for_diagnostic(); + snapshot.bump(); + match snapshot.parse_seq_to_before_end( + &token::CloseDelim(Delimiter::Bracket), + SeqSep::trailing_allowed(token::Comma), + |p| p.parse_expr(), + ) { + Ok(_) + // When the close delim is `)`, `token.kind` is expected to be `token::CloseDelim(Delimiter::Parenthesis)`, + // but the actual `token.kind` is `token::CloseDelim(Delimiter::Bracket)`. + // This is because the `token.kind` of the close delim is treated as the same as + // that of the open delim in `TokenTreesReader::parse_token_tree`, even if the delimiters of them are different. + // Therefore, `token.kind` should not be compared here. + if snapshot + .span_to_snippet(snapshot.token.span) + .map_or(false, |snippet| snippet == "]") => + { + let mut err = self.struct_span_err(open_delim_span, "expected `;`, found `[`"); + err.span_suggestion_verbose( + prev_span.shrink_to_hi(), + "consider adding `;` here", + ';', + Applicability::MaybeIncorrect, + ); + return Err(err); + } + Ok(_) => (), + Err(err) => err.cancel(), + } + } + Ok(()) + } + /// Parses a block or unsafe block. pub(super) fn parse_block_expr( &mut self, |
