Skip to content

Commit 5d39f1f

Browse files
committed
Auto merge of rust-lang#73147 - Dylan-DPC:rollup-9saqhj5, r=Dylan-DPC
Rollup of 8 pull requests Successful merges: - rust-lang#71842 (doc: make impl block collapsible if it has an associated constant) - rust-lang#72912 (Add new E0758 error code) - rust-lang#73008 (Update RELEASES.md) - rust-lang#73090 (Use `LocalDefId` directly in `Resolver::export_map`) - rust-lang#73118 (Improve the wording in documentation of std::mem::drop) - rust-lang#73124 (Removed lifetime parameters from Explanation of E0207 ) - rust-lang#73138 (Use shorthand linker strip arguments in order to support MacOS) - rust-lang#73143 (Update books) Failed merges: r? @ghost
2 parents fd4b177 + 9890107 commit 5d39f1f

File tree

23 files changed

+92
-49
lines changed

23 files changed

+92
-49
lines changed

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Compiler
2525
--------
2626
- [Rustc now respects the `-C codegen-units` flag in incremental mode.][70156]
2727
Additionally when in incremental mode rustc defaults to 256 codegen units.
28-
- [Refactored `catch_unwind`, to have zero-cost unless unwinding is enabled and
28+
- [Refactored `catch_unwind` to have zero-cost, unless unwinding is enabled and
2929
a panic is thrown.][67502]
3030
- [Added tier 3\* support for the `aarch64-unknown-none` and
3131
`aarch64-unknown-none-softfloat` targets.][68334]

src/doc/book

Submodule book updated 72 files

src/libcore/mem/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ pub fn replace<T>(dest: &mut T, mut src: T) -> T {
808808

809809
/// Disposes of a value.
810810
///
811-
/// This does call the argument's implementation of [`Drop`][drop].
811+
/// This does so by calling the argument's implementation of [`Drop`][drop].
812812
///
813813
/// This effectively does nothing for types which implement `Copy`, e.g.
814814
/// integers. Such values are copied and _then_ moved into the function, so the

src/librustc_codegen_ssa/back/linker.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,12 @@ impl<'a> Linker for GccLinker<'a> {
481481
match strip {
482482
Strip::None => {}
483483
Strip::Debuginfo => {
484-
self.linker_arg("--strip-debug");
484+
// MacOS linker does not support longhand argument --strip-debug
485+
self.linker_arg("-S");
485486
}
486487
Strip::Symbols => {
487-
self.linker_arg("--strip-all");
488+
// MacOS linker does not support longhand argument --strip-all
489+
self.linker_arg("-s");
488490
}
489491
}
490492
}

src/librustc_error_codes/error_codes.rs

+1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ E0751: include_str!("./error_codes/E0751.md"),
437437
E0752: include_str!("./error_codes/E0752.md"),
438438
E0753: include_str!("./error_codes/E0753.md"),
439439
E0754: include_str!("./error_codes/E0754.md"),
440+
E0758: include_str!("./error_codes/E0758.md"),
440441
E0760: include_str!("./error_codes/E0760.md"),
441442
;
442443
// E0006, // merged with E0005

src/librustc_error_codes/error_codes/E0207.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
A type or lifetime parameter that is specified for `impl` is not constrained.
1+
A type parameter that is specified for `impl` is not constrained.
22

33
Erroneous code example:
44

@@ -14,7 +14,7 @@ impl<T: Default> Foo {
1414
}
1515
```
1616

17-
Any type parameter or lifetime parameter of an `impl` must meet at least one of
17+
Any type parameter parameter of an `impl` must meet at least one of
1818
the following criteria:
1919

2020
- it appears in the _implementing type_ of the impl, e.g. `impl<T> Foo<T>`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
A multi-line (doc-)comment is unterminated.
2+
3+
Erroneous code example:
4+
5+
```compile_fail,E0758
6+
/* I am not terminated!
7+
```
8+
9+
The same goes for doc comments:
10+
11+
```compile_fail,E0758
12+
/*! I am not terminated!
13+
```
14+
15+
You need to end your multi-line comment with `*/` in order to fix this error:
16+
17+
```
18+
/* I am terminated! */
19+
/*! I am also terminated! */
20+
```

src/librustc_metadata/rmeta/encoder.rs

+11-2
Original file line numberDiff line numberDiff line change
@@ -693,16 +693,25 @@ impl EncodeContext<'tcx> {
693693
vis: &hir::Visibility<'_>,
694694
) {
695695
let tcx = self.tcx;
696-
let def_id = tcx.hir().local_def_id(id).to_def_id();
696+
let def_id = tcx.hir().local_def_id(id);
697697
debug!("EncodeContext::encode_info_for_mod({:?})", def_id);
698698

699699
let data = ModData {
700700
reexports: match tcx.module_exports(def_id) {
701-
Some(exports) => self.lazy(exports),
701+
Some(exports) => {
702+
let hir_map = self.tcx.hir();
703+
self.lazy(
704+
exports
705+
.iter()
706+
.map(|export| export.map_id(|id| hir_map.as_local_hir_id(id))),
707+
)
708+
}
702709
_ => Lazy::empty(),
703710
},
704711
};
705712

713+
let def_id = def_id.to_def_id();
714+
706715
record!(self.tables.kind[def_id] <- EntryKind::Mod(self.lazy(data)));
707716
record!(self.tables.visibility[def_id] <- ty::Visibility::from_hir(vis, id, self.tcx));
708717
record!(self.tables.span[def_id] <- self.tcx.def_span(def_id));

src/librustc_middle/hir/exports.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use crate::ty;
22

3+
use rustc_data_structures::fx::FxHashMap;
34
use rustc_hir::def::Res;
4-
use rustc_hir::def_id::DefIdMap;
5+
use rustc_hir::def_id::LocalDefId;
56
use rustc_macros::HashStable;
67
use rustc_span::symbol::Ident;
78
use rustc_span::Span;
@@ -10,7 +11,7 @@ use std::fmt::Debug;
1011

1112
/// This is the replacement export map. It maps a module to all of the exports
1213
/// within.
13-
pub type ExportMap<Id> = DefIdMap<Vec<Export<Id>>>;
14+
pub type ExportMap<Id> = FxHashMap<LocalDefId, Vec<Export<Id>>>;
1415

1516
#[derive(Copy, Clone, Debug, RustcEncodable, RustcDecodable, HashStable)]
1617
pub struct Export<Id> {

src/librustc_middle/query/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,8 @@ rustc_queries! {
865865
}
866866

867867
Other {
868-
query module_exports(def_id: DefId) -> Option<&'tcx [Export<hir::HirId>]> {
869-
desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id) }
868+
query module_exports(def_id: LocalDefId) -> Option<&'tcx [Export<LocalDefId>]> {
869+
desc { |tcx| "looking up items exported by `{}`", tcx.def_path_str(def_id.to_def_id()) }
870870
eval_always
871871
}
872872
}

src/librustc_middle/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::arena::Arena;
44
use crate::dep_graph::{self, DepConstructor, DepGraph};
5-
use crate::hir::exports::Export;
5+
use crate::hir::exports::ExportMap;
66
use crate::ich::{NodeIdHashingMode, StableHashingContext};
77
use crate::infer::canonical::{Canonical, CanonicalVarInfo, CanonicalVarInfos};
88
use crate::lint::{struct_lint_level, LintDiagnosticBuilder, LintSource};
@@ -919,7 +919,7 @@ pub struct GlobalCtxt<'tcx> {
919919
trait_map: FxHashMap<LocalDefId, FxHashMap<ItemLocalId, StableVec<TraitCandidate>>>,
920920

921921
/// Export map produced by name resolution.
922-
export_map: FxHashMap<DefId, Vec<Export<hir::HirId>>>,
922+
export_map: ExportMap<LocalDefId>,
923923

924924
pub(crate) untracked_crate: &'tcx hir::Crate<'tcx>,
925925
pub(crate) definitions: &'tcx Definitions,

src/librustc_middle/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub struct ResolverOutputs {
124124
pub trait_map: FxHashMap<hir::HirId, Vec<hir::TraitCandidate<hir::HirId>>>,
125125
pub maybe_unused_trait_imports: FxHashSet<LocalDefId>,
126126
pub maybe_unused_extern_crates: Vec<(LocalDefId, Span)>,
127-
pub export_map: ExportMap<hir::HirId>,
127+
pub export_map: ExportMap<LocalDefId>,
128128
pub glob_map: FxHashMap<LocalDefId, FxHashSet<Symbol>>,
129129
/// Extern prelude entries. The value is `true` if the entry was introduced
130130
/// via `extern crate` item and not `--extern` option or compiler built-in.

src/librustc_parse/lexer/mod.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,15 @@ impl<'a> StringReader<'a> {
191191
"unterminated block comment"
192192
};
193193
let last_bpos = self.pos;
194-
self.fatal_span_(start, last_bpos, msg).raise();
194+
self.sess
195+
.span_diagnostic
196+
.struct_span_fatal_with_code(
197+
self.mk_sp(start, last_bpos),
198+
msg,
199+
error_code!(E0758),
200+
)
201+
.emit();
202+
FatalError.raise();
195203
}
196204

197205
if is_doc_comment {

src/librustc_resolve/imports.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -1393,8 +1393,8 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
13931393
let is_good_import =
13941394
binding.is_import() && !binding.is_ambiguity() && !ident.span.from_expansion();
13951395
if is_good_import || binding.is_macro_def() {
1396-
let res = binding.res();
1397-
if res != Res::Err {
1396+
let res = binding.res().map_id(|id| this.definitions.local_def_id(id));
1397+
if res != def::Res::Err {
13981398
reexports.push(Export { ident, res, span: binding.span, vis: binding.vis });
13991399
}
14001400
}
@@ -1467,7 +1467,9 @@ impl<'a, 'b> ImportResolver<'a, 'b> {
14671467

14681468
if !reexports.is_empty() {
14691469
if let Some(def_id) = module.def_id() {
1470-
self.r.export_map.insert(def_id, reexports);
1470+
// Call to `expect_local` should be fine because current
1471+
// code is only called for local modules.
1472+
self.r.export_map.insert(def_id.expect_local(), reexports);
14711473
}
14721474
}
14731475
}

src/librustc_resolve/lib.rs

+3-25
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ pub struct Resolver<'a> {
878878

879879
/// `CrateNum` resolutions of `extern crate` items.
880880
extern_crate_map: FxHashMap<LocalDefId, CrateNum>,
881-
export_map: ExportMap<NodeId>,
881+
export_map: ExportMap<LocalDefId>,
882882
trait_map: TraitMap<NodeId>,
883883

884884
/// A map from nodes to anonymous modules.
@@ -1281,18 +1281,7 @@ impl<'a> Resolver<'a> {
12811281
pub fn into_outputs(self) -> ResolverOutputs {
12821282
let definitions = self.definitions;
12831283
let extern_crate_map = self.extern_crate_map;
1284-
let export_map = self
1285-
.export_map
1286-
.into_iter()
1287-
.map(|(k, v)| {
1288-
(
1289-
k,
1290-
v.into_iter()
1291-
.map(|e| e.map_id(|id| definitions.node_id_to_hir_id(id)))
1292-
.collect(),
1293-
)
1294-
})
1295-
.collect();
1284+
let export_map = self.export_map;
12961285
let trait_map = self
12971286
.trait_map
12981287
.into_iter()
@@ -1330,18 +1319,7 @@ impl<'a> Resolver<'a> {
13301319
definitions: self.definitions.clone(),
13311320
cstore: Box::new(self.cstore().clone()),
13321321
extern_crate_map: self.extern_crate_map.clone(),
1333-
export_map: self
1334-
.export_map
1335-
.iter()
1336-
.map(|(&k, v)| {
1337-
(
1338-
k,
1339-
v.iter()
1340-
.map(|e| e.map_id(|id| self.definitions.node_id_to_hir_id(id)))
1341-
.collect(),
1342-
)
1343-
})
1344-
.collect(),
1322+
export_map: self.export_map.clone(),
13451323
trait_map: self
13461324
.trait_map
13471325
.iter()

src/librustdoc/html/static/main.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -2374,7 +2374,9 @@ function defocusSearchBar() {
23742374
if (!next) {
23752375
return;
23762376
}
2377-
if (next.getElementsByClassName("method").length > 0 && hasClass(e, "impl")) {
2377+
if (hasClass(e, "impl") &&
2378+
(next.getElementsByClassName("method").length > 0 ||
2379+
next.getElementsByClassName("associatedconstant").length > 0)) {
23782380
insertAfter(toggle.cloneNode(true), e.childNodes[e.childNodes.length - 1]);
23792381
}
23802382
};

src/test/ui/unterminated-comment.rs

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* //~ ERROR E0758
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0758]: unterminated block comment
2+
--> $DIR/unterminated-comment.rs:1:1
3+
|
4+
LL | /*
5+
| ^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0758`.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*! //~ ERROR E0758
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0758]: unterminated block doc-comment
2+
--> $DIR/unterminated-doc-comment.rs:1:1
3+
|
4+
LL | /*!
5+
| ^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0758`.

0 commit comments

Comments
 (0)