Skip to content

Commit 05c0738

Browse files
committed
Auto merge of rust-lang#96566 - Dylan-DPC:rollup-fo7rd98, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - rust-lang#96390 (Switch JS code to ES6 - part 2) - rust-lang#96527 (RustWrapper: explicitly don't handle DXILPointerTyID) - rust-lang#96536 (rustdoc: fix missing method list for primitive deref target) - rust-lang#96559 (Use the correct lifetime binder for elided lifetimes in path.) - rust-lang#96560 (Remove unnecessary environment variable in cf-protection documentation) - rust-lang#96562 (Fix duplicate directory separator in --remap-path-prefix.) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents a707f40 + 548fca6 commit 05c0738

File tree

16 files changed

+437
-298
lines changed

16 files changed

+437
-298
lines changed

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,11 @@ extern "C" LLVMTypeKind LLVMRustGetTypeKind(LLVMTypeRef Ty) {
12171217
return LLVMBFloatTypeKind;
12181218
case Type::X86_AMXTyID:
12191219
return LLVMX86_AMXTypeKind;
1220+
#if LLVM_VERSION_GE(15, 0)
1221+
case Type::DXILPointerTyID:
1222+
report_fatal_error("Rust does not support DirectX typed pointers.");
1223+
break;
1224+
#endif
12201225
}
12211226
report_fatal_error("Unhandled TypeID.");
12221227
}

compiler/rustc_resolve/src/late.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -1319,7 +1319,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13191319
| PathSource::Struct
13201320
| PathSource::TupleStruct(..) => false,
13211321
};
1322-
let mut error = false;
1322+
let mut res = LifetimeRes::Error;
13231323
for rib in self.lifetime_ribs.iter().rev() {
13241324
match rib.kind {
13251325
// In create-parameter mode we error here because we don't want to support
@@ -1329,7 +1329,6 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13291329
// impl Foo for std::cell::Ref<u32> // note lack of '_
13301330
// async fn foo(_: std::cell::Ref<u32>) { ... }
13311331
LifetimeRibKind::AnonymousCreateParameter(_) => {
1332-
error = true;
13331332
break;
13341333
}
13351334
// `PassThrough` is the normal case.
@@ -1338,19 +1337,21 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13381337
// `PathSegment`, for which there is no associated `'_` or `&T` with no explicit
13391338
// lifetime. Instead, we simply create an implicit lifetime, which will be checked
13401339
// later, at which point a suitable error will be emitted.
1341-
LifetimeRibKind::AnonymousPassThrough(..)
1342-
| LifetimeRibKind::AnonymousReportError
1343-
| LifetimeRibKind::Item => break,
1340+
LifetimeRibKind::AnonymousPassThrough(binder) => {
1341+
res = LifetimeRes::Anonymous { binder, elided: true };
1342+
break;
1343+
}
1344+
LifetimeRibKind::AnonymousReportError | LifetimeRibKind::Item => {
1345+
// FIXME(cjgillot) This resolution is wrong, but this does not matter
1346+
// since these cases are erroneous anyway. Lifetime resolution should
1347+
// emit a "missing lifetime specifier" diagnostic.
1348+
res = LifetimeRes::Anonymous { binder: DUMMY_NODE_ID, elided: true };
1349+
break;
1350+
}
13441351
_ => {}
13451352
}
13461353
}
13471354

1348-
let res = if error {
1349-
LifetimeRes::Error
1350-
} else {
1351-
LifetimeRes::Anonymous { binder: segment_id, elided: true }
1352-
};
1353-
13541355
let node_ids = self.r.next_node_ids(expected_lifetimes);
13551356
self.record_lifetime_res(
13561357
segment_id,
@@ -1374,7 +1375,7 @@ impl<'a: 'ast, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
13741375
// originating from macros, since the segment's span might be from a macro arg.
13751376
segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span)
13761377
};
1377-
if error {
1378+
if let LifetimeRes::Error = res {
13781379
let sess = self.r.session;
13791380
let mut err = rustc_errors::struct_span_err!(
13801381
sess,

compiler/rustc_span/src/source_map.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,19 @@ impl FilePathMapping {
11021102
// take precedence.
11031103
for &(ref from, ref to) in self.mapping.iter().rev() {
11041104
if let Ok(rest) = path.strip_prefix(from) {
1105-
return (to.join(rest), true);
1105+
let remapped = if rest.as_os_str().is_empty() {
1106+
// This is subtle, joining an empty path onto e.g. `foo/bar` will
1107+
// result in `foo/bar/`, that is, there'll be an additional directory
1108+
// separator at the end. This can lead to duplicated directory separators
1109+
// in remapped paths down the line.
1110+
// So, if we have an exact match, we just return that without a call
1111+
// to `Path::join()`.
1112+
to.clone()
1113+
} else {
1114+
to.join(rest)
1115+
};
1116+
1117+
return (remapped, true);
11061118
}
11071119
}
11081120

compiler/rustc_span/src/source_map/tests.rs

+80
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,83 @@ impl SourceMapExtension for SourceMap {
312312
}
313313
}
314314
}
315+
316+
fn map_path_prefix(mapping: &FilePathMapping, path: &str) -> String {
317+
// It's important that we convert to a string here because that's what
318+
// later stages do too (e.g. in the backend), and comparing `Path` values
319+
// won't catch some differences at the string level, e.g. "abc" and "abc/"
320+
// compare as equal.
321+
mapping.map_prefix(path.into()).0.to_string_lossy().to_string()
322+
}
323+
324+
#[cfg(unix)]
325+
#[test]
326+
fn path_prefix_remapping() {
327+
// Relative to relative
328+
{
329+
let mapping = &FilePathMapping::new(vec![("abc/def".into(), "foo".into())]);
330+
331+
assert_eq!(map_path_prefix(mapping, "abc/def/src/main.rs"), "foo/src/main.rs");
332+
assert_eq!(map_path_prefix(mapping, "abc/def"), "foo");
333+
}
334+
335+
// Relative to absolute
336+
{
337+
let mapping = &FilePathMapping::new(vec![("abc/def".into(), "/foo".into())]);
338+
339+
assert_eq!(map_path_prefix(mapping, "abc/def/src/main.rs"), "/foo/src/main.rs");
340+
assert_eq!(map_path_prefix(mapping, "abc/def"), "/foo");
341+
}
342+
343+
// Absolute to relative
344+
{
345+
let mapping = &FilePathMapping::new(vec![("/abc/def".into(), "foo".into())]);
346+
347+
assert_eq!(map_path_prefix(mapping, "/abc/def/src/main.rs"), "foo/src/main.rs");
348+
assert_eq!(map_path_prefix(mapping, "/abc/def"), "foo");
349+
}
350+
351+
// Absolute to absolute
352+
{
353+
let mapping = &FilePathMapping::new(vec![("/abc/def".into(), "/foo".into())]);
354+
355+
assert_eq!(map_path_prefix(mapping, "/abc/def/src/main.rs"), "/foo/src/main.rs");
356+
assert_eq!(map_path_prefix(mapping, "/abc/def"), "/foo");
357+
}
358+
}
359+
360+
#[cfg(windows)]
361+
#[test]
362+
fn path_prefix_remapping_from_relative2() {
363+
// Relative to relative
364+
{
365+
let mapping = &FilePathMapping::new(vec![("abc\\def".into(), "foo".into())]);
366+
367+
assert_eq!(map_path_prefix(mapping, "abc\\def\\src\\main.rs"), "foo\\src\\main.rs");
368+
assert_eq!(map_path_prefix(mapping, "abc\\def"), "foo");
369+
}
370+
371+
// Relative to absolute
372+
{
373+
let mapping = &FilePathMapping::new(vec![("abc\\def".into(), "X:\\foo".into())]);
374+
375+
assert_eq!(map_path_prefix(mapping, "abc\\def\\src\\main.rs"), "X:\\foo\\src\\main.rs");
376+
assert_eq!(map_path_prefix(mapping, "abc\\def"), "X:\\foo");
377+
}
378+
379+
// Absolute to relative
380+
{
381+
let mapping = &FilePathMapping::new(vec![("X:\\abc\\def".into(), "foo".into())]);
382+
383+
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def\\src\\main.rs"), "foo\\src\\main.rs");
384+
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def"), "foo");
385+
}
386+
387+
// Absolute to absolute
388+
{
389+
let mapping = &FilePathMapping::new(vec![("X:\\abc\\def".into(), "X:\\foo".into())]);
390+
391+
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def\\src\\main.rs"), "X:\\foo\\src\\main.rs");
392+
assert_eq!(map_path_prefix(mapping, "X:\\abc\\def"), "X:\\foo");
393+
}
394+
}

src/doc/unstable-book/src/compiler-flags/cf-protection.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ standard library does not ship with CET enabled by default, so you may need to r
1717
modules with a `cargo` command like:
1818

1919
```sh
20-
$ RUSTFLAGS="-Z cf-protection=full" RUSTC="rustc-custom" cargo +nightly build -Z build-std --target x86_64-unknown-linux-gnu
20+
$ RUSTFLAGS="-Z cf-protection=full" cargo +nightly build -Z build-std --target x86_64-unknown-linux-gnu
2121
```
2222

2323
### Detection

src/librustdoc/html/static/js/externs.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
// This file contains type definitions that are processed by the Closure Compiler but are
22
// not put into the JavaScript we include as part of the documentation. It is used for
33
// type checking. See README.md in this directory for more info.
4+
/* eslint-env es6 */
5+
/* eslint no-var: "error" */
6+
/* eslint prefer-const: "error" */
47

58
/* eslint-disable */
6-
var searchState;
9+
let searchState;
710
function initSearch(searchIndex){}
811

912
/**
@@ -15,7 +18,7 @@ function initSearch(searchIndex){}
1518
* generics: Array<QueryElement>,
1619
* }}
1720
*/
18-
var QueryElement;
21+
let QueryElement;
1922

2023
/**
2124
* @typedef {{
@@ -25,7 +28,7 @@ var QueryElement;
2528
* userQuery: string,
2629
* }}
2730
*/
28-
var ParserState;
31+
let ParserState;
2932

3033
/**
3134
* @typedef {{
@@ -38,7 +41,7 @@ var ParserState;
3841
* foundElems: number,
3942
* }}
4043
*/
41-
var ParsedQuery;
44+
let ParsedQuery;
4245

4346
/**
4447
* @typedef {{
@@ -53,7 +56,7 @@ var ParsedQuery;
5356
* type: (Array<?>|null)
5457
* }}
5558
*/
56-
var Row;
59+
let Row;
5760

5861
/**
5962
* @typedef {{
@@ -63,7 +66,7 @@ var Row;
6366
* query: ParsedQuery,
6467
* }}
6568
*/
66-
var ResultsTable;
69+
let ResultsTable;
6770

6871
/**
6972
* @typedef {{
@@ -80,4 +83,4 @@ var ResultsTable;
8083
* ty: number,
8184
* }}
8285
*/
83-
var Results;
86+
let Results;

0 commit comments

Comments
 (0)