Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ee933f6

Browse files
committedFeb 26, 2024
Auto merge of rust-lang#121627 - GuillaumeGomez:rollup-udp3m0k, r=GuillaumeGomez
Rollup of 5 pull requests Successful merges: - rust-lang#120656 (Allow tests to specify a `//@ filecheck-flags:` header) - rust-lang#120840 (Split Diagnostics for Uncommon Codepoints: Add Individual Identifier Types) - rust-lang#121554 (Don't unnecessarily change `SIGPIPE` disposition in `unix_sigpipe` tests) - rust-lang#121590 (Correctly handle if rustdoc JS script hash changed) - rust-lang#121620 (Fix more rust-lang#121208 fallout (round 3)) r? `@ghost` `@rustbot` modify labels: rollup
2 parents dc00e8c + 76f303d commit ee933f6

File tree

30 files changed

+399
-198
lines changed

30 files changed

+399
-198
lines changed
 

‎compiler/rustc_hir_analysis/src/collect/resolve_bound_vars.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ impl<'a, 'tcx> BoundVarContext<'a, 'tcx> {
13311331
}
13321332
}
13331333

1334-
self.tcx.dcx().span_bug(
1334+
self.tcx.dcx().span_delayed_bug(
13351335
lifetime_ref.ident.span,
13361336
format!("Could not resolve {:?} in scope {:#?}", lifetime_ref, self.scope,),
13371337
);

‎compiler/rustc_hir_typeck/src/method/probe.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,10 +804,11 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
804804
let trait_ref = principal.with_self_ty(self.tcx, self_ty);
805805
self.elaborate_bounds(iter::once(trait_ref), |this, new_trait_ref, item| {
806806
if new_trait_ref.has_non_region_bound_vars() {
807-
this.dcx().span_bug(
807+
this.dcx().span_delayed_bug(
808808
this.span,
809809
"tried to select method from HRTB with non-lifetime bound vars",
810810
);
811+
return;
811812
}
812813

813814
let new_trait_ref = this.instantiate_bound_regions_with_erased(new_trait_ref);

‎compiler/rustc_lint/messages.ftl

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,28 @@ lint_hidden_unicode_codepoints = unicode codepoint changing visible direction of
244244
lint_identifier_non_ascii_char = identifier contains non-ASCII characters
245245
246246
lint_identifier_uncommon_codepoints = identifier contains {$codepoints_len ->
247-
[one] an uncommon Unicode codepoint
248-
*[other] uncommon Unicode codepoints
247+
[one] { $identifier_type ->
248+
[Exclusion] a character from an archaic script
249+
[Technical] a character that is for non-linguistic, specialized usage
250+
[Limited_Use] a character from a script in limited use
251+
[Not_NFKC] a non normalized (NFKC) character
252+
*[other] an uncommon character
253+
}
254+
*[other] { $identifier_type ->
255+
[Exclusion] {$codepoints_len} characters from archaic scripts
256+
[Technical] {$codepoints_len} characters that are for non-linguistic, specialized usage
257+
[Limited_Use] {$codepoints_len} characters from scripts in limited use
258+
[Not_NFKC] {$codepoints_len} non normalized (NFKC) characters
259+
*[other] uncommon characters
260+
}
249261
}: {$codepoints}
262+
.note = {$codepoints_len ->
263+
[one] this character is
264+
*[other] these characters are
265+
} included in the{$identifier_type ->
266+
[Restricted] {""}
267+
*[other] {" "}{$identifier_type}
268+
} Unicode general security profile
250269
251270
lint_ignored_unless_crate_specified = {$level}({$name}) is ignored unless specified at crate level
252271

‎compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![feature(array_windows)]
3232
#![feature(box_patterns)]
3333
#![feature(control_flow_enum)]
34+
#![feature(extract_if)]
3435
#![feature(generic_nonzero)]
3536
#![feature(if_let_guard)]
3637
#![feature(iter_order_by)]

‎compiler/rustc_lint/src/lints.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,9 +1129,11 @@ pub struct IdentifierNonAsciiChar;
11291129

11301130
#[derive(LintDiagnostic)]
11311131
#[diag(lint_identifier_uncommon_codepoints)]
1132+
#[note]
11321133
pub struct IdentifierUncommonCodepoints {
11331134
pub codepoints: Vec<char>,
11341135
pub codepoints_len: usize,
1136+
pub identifier_type: &'static str,
11351137
}
11361138

11371139
#[derive(LintDiagnostic)]

‎compiler/rustc_lint/src/non_ascii_idents.rs

Lines changed: 39 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use rustc_ast as ast;
77
use rustc_data_structures::fx::FxIndexMap;
88
use rustc_data_structures::unord::UnordMap;
99
use rustc_span::symbol::Symbol;
10+
use unicode_security::general_security_profile::IdentifierType;
1011

1112
declare_lint! {
1213
/// The `non_ascii_idents` lint detects non-ASCII identifiers.
@@ -189,17 +190,47 @@ impl EarlyLintPass for NonAsciiIdents {
189190
if check_uncommon_codepoints
190191
&& !symbol_str.chars().all(GeneralSecurityProfile::identifier_allowed)
191192
{
192-
let codepoints: Vec<_> = symbol_str
193+
let mut chars: Vec<_> = symbol_str
193194
.chars()
194-
.filter(|c| !GeneralSecurityProfile::identifier_allowed(*c))
195+
.map(|c| (c, GeneralSecurityProfile::identifier_type(c)))
195196
.collect();
196-
let codepoints_len = codepoints.len();
197197

198-
cx.emit_span_lint(
199-
UNCOMMON_CODEPOINTS,
200-
sp,
201-
IdentifierUncommonCodepoints { codepoints, codepoints_len },
202-
);
198+
for (id_ty, id_ty_descr) in [
199+
(IdentifierType::Exclusion, "Exclusion"),
200+
(IdentifierType::Technical, "Technical"),
201+
(IdentifierType::Limited_Use, "Limited_Use"),
202+
(IdentifierType::Not_NFKC, "Not_NFKC"),
203+
] {
204+
let codepoints: Vec<_> =
205+
chars.extract_if(|(_, ty)| *ty == Some(id_ty)).collect();
206+
if codepoints.is_empty() {
207+
continue;
208+
}
209+
cx.emit_span_lint(
210+
UNCOMMON_CODEPOINTS,
211+
sp,
212+
IdentifierUncommonCodepoints {
213+
codepoints_len: codepoints.len(),
214+
codepoints: codepoints.into_iter().map(|(c, _)| c).collect(),
215+
identifier_type: id_ty_descr,
216+
},
217+
);
218+
}
219+
220+
let remaining = chars
221+
.extract_if(|(c, _)| !GeneralSecurityProfile::identifier_allowed(*c))
222+
.collect::<Vec<_>>();
223+
if !remaining.is_empty() {
224+
cx.emit_span_lint(
225+
UNCOMMON_CODEPOINTS,
226+
sp,
227+
IdentifierUncommonCodepoints {
228+
codepoints_len: remaining.len(),
229+
codepoints: remaining.into_iter().map(|(c, _)| c).collect(),
230+
identifier_type: "Restricted",
231+
},
232+
);
233+
}
203234
}
204235
}
205236

‎src/librustdoc/html/static/js/main.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,12 @@ function preLoadCss(cssUrl) {
185185
(function() {
186186
const isHelpPage = window.location.pathname.endsWith("/help.html");
187187

188-
function loadScript(url) {
188+
function loadScript(url, errorCallback) {
189189
const script = document.createElement("script");
190190
script.src = url;
191+
if (errorCallback !== undefined) {
192+
script.onerror = errorCallback;
193+
}
191194
document.head.append(script);
192195
}
193196

@@ -292,11 +295,16 @@ function preLoadCss(cssUrl) {
292295
return;
293296
}
294297
let searchLoaded = false;
298+
// If you're browsing the nightly docs, the page might need to be refreshed for the
299+
// search to work because the hash of the JS scripts might have changed.
300+
function sendSearchForm() {
301+
document.getElementsByClassName("search-form")[0].submit();
302+
}
295303
function loadSearch() {
296304
if (!searchLoaded) {
297305
searchLoaded = true;
298-
loadScript(getVar("static-root-path") + getVar("search-js"));
299-
loadScript(resourcePath("search-index", ".js"));
306+
loadScript(getVar("static-root-path") + getVar("search-js"), sendSearchForm);
307+
loadScript(resourcePath("search-index", ".js"), sendSearchForm);
300308
}
301309
}
302310

‎src/tools/compiletest/src/header.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,8 @@ pub struct TestProps {
197197
/// Extra flags to pass to `llvm-cov` when producing coverage reports.
198198
/// Only used by the "coverage-run" test mode.
199199
pub llvm_cov_flags: Vec<String>,
200+
/// Extra flags to pass to LLVM's `filecheck` tool, in tests that use it.
201+
pub filecheck_flags: Vec<String>,
200202
}
201203

202204
mod directives {
@@ -236,6 +238,7 @@ mod directives {
236238
pub const REMAP_SRC_BASE: &'static str = "remap-src-base";
237239
pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset";
238240
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
241+
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
239242
// This isn't a real directive, just one that is probably mistyped often
240243
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
241244
}
@@ -286,6 +289,7 @@ impl TestProps {
286289
mir_unit_test: None,
287290
remap_src_base: false,
288291
llvm_cov_flags: vec![],
292+
filecheck_flags: vec![],
289293
}
290294
}
291295

@@ -542,6 +546,10 @@ impl TestProps {
542546
if let Some(flags) = config.parse_name_value_directive(ln, LLVM_COV_FLAGS) {
543547
self.llvm_cov_flags.extend(split_flags(&flags));
544548
}
549+
550+
if let Some(flags) = config.parse_name_value_directive(ln, FILECHECK_FLAGS) {
551+
self.filecheck_flags.extend(split_flags(&flags));
552+
}
545553
},
546554
);
547555

‎src/tools/compiletest/src/runtest.rs

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2909,25 +2909,32 @@ impl<'test> TestCx<'test> {
29092909
fn verify_with_filecheck(&self, output: &Path) -> ProcRes {
29102910
let mut filecheck = Command::new(self.config.llvm_filecheck.as_ref().unwrap());
29112911
filecheck.arg("--input-file").arg(output).arg(&self.testpaths.file);
2912-
// It would be more appropriate to make most of the arguments configurable through
2913-
// a comment-attribute similar to `compile-flags`. For example, --check-prefixes is a very
2914-
// useful flag.
2915-
//
2916-
// For now, though…
2917-
let prefix_for_target =
2918-
if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
2919-
let prefixes = if let Some(rev) = self.revision {
2920-
format!("CHECK,{},{}", prefix_for_target, rev)
2921-
} else {
2922-
format!("CHECK,{}", prefix_for_target)
2923-
};
2924-
if self.config.llvm_version.unwrap_or(0) >= 130000 {
2925-
filecheck.args(&["--allow-unused-prefixes", "--check-prefixes", &prefixes]);
2926-
} else {
2927-
filecheck.args(&["--check-prefixes", &prefixes]);
2912+
2913+
// FIXME: Consider making some of these prefix flags opt-in per test,
2914+
// via `filecheck-flags` or by adding new header directives.
2915+
2916+
// Because we use custom prefixes, we also have to register the default prefix.
2917+
filecheck.arg("--check-prefix=CHECK");
2918+
2919+
// Some tests use the current revision name as a check prefix.
2920+
if let Some(rev) = self.revision {
2921+
filecheck.arg("--check-prefix").arg(rev);
29282922
}
2923+
2924+
// Some tests also expect either the MSVC or NONMSVC prefix to be defined.
2925+
let msvc_or_not = if self.config.target.contains("msvc") { "MSVC" } else { "NONMSVC" };
2926+
filecheck.arg("--check-prefix").arg(msvc_or_not);
2927+
2928+
// The filecheck tool normally fails if a prefix is defined but not used.
2929+
// However, we define several prefixes globally for all tests.
2930+
filecheck.arg("--allow-unused-prefixes");
2931+
29292932
// Provide more context on failures.
29302933
filecheck.args(&["--dump-input-context", "100"]);
2934+
2935+
// Add custom flags supplied by the `filecheck-flags:` test header.
2936+
filecheck.args(&self.props.filecheck_flags);
2937+
29312938
self.compose_and_run(filecheck, "", None, None)
29322939
}
29332940

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
//@ edition: 2021
2+
//@ needs-profiler-support
3+
//@ compile-flags: -Cinstrument-coverage -Copt-level=0
4+
//@ revisions: LINUX DARWIN WINDOWS
5+
6+
//@ [LINUX] only-linux
7+
//@ [LINUX] filecheck-flags: -DINSTR_PROF_DATA=__llvm_prf_data
8+
//@ [LINUX] filecheck-flags: -DINSTR_PROF_NAME=__llvm_prf_names
9+
//@ [LINUX] filecheck-flags: -DINSTR_PROF_CNTS=__llvm_prf_cnts
10+
//@ [LINUX] filecheck-flags: -DINSTR_PROF_COVMAP=__llvm_covmap
11+
//@ [LINUX] filecheck-flags: -DINSTR_PROF_COVFUN=__llvm_covfun
12+
//@ [LINUX] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat'
13+
14+
//@ [DARWIN] only-macos
15+
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_DATA=__DATA,__llvm_prf_data,regular,live_support
16+
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_NAME=__DATA,__llvm_prf_names
17+
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_CNTS=__DATA,__llvm_prf_cnts
18+
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_COVMAP=__LLVM_COV,__llvm_covmap
19+
//@ [DARWIN] filecheck-flags: -DINSTR_PROF_COVFUN=__LLVM_COV,__llvm_covfun
20+
//@ [DARWIN] filecheck-flags: -DCOMDAT_IF_SUPPORTED=
21+
22+
//@ [WINDOWS] only-windows
23+
//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_DATA=.lprfd$M
24+
//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_NAME=.lprfn$M
25+
//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_CNTS=.lprfc$M
26+
//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_COVMAP=.lcovmap$M
27+
//@ [WINDOWS] filecheck-flags: -DINSTR_PROF_COVFUN=.lcovfun$M
28+
//@ [WINDOWS] filecheck-flags: '-DCOMDAT_IF_SUPPORTED=, comdat'
29+
30+
// ignore-tidy-linelength
31+
32+
pub fn will_be_called() -> &'static str {
33+
let val = "called";
34+
println!("{}", val);
35+
val
36+
}
37+
38+
pub fn will_not_be_called() -> bool {
39+
println!("should not have been called");
40+
false
41+
}
42+
43+
pub fn print<T>(left: &str, value: T, right: &str)
44+
where
45+
T: std::fmt::Display,
46+
{
47+
println!("{}{}{}", left, value, right);
48+
}
49+
50+
pub fn wrap_with<F, T>(inner: T, should_wrap: bool, wrapper: F)
51+
where
52+
F: FnOnce(&T)
53+
{
54+
if should_wrap {
55+
wrapper(&inner)
56+
}
57+
}
58+
59+
fn main() {
60+
let less = 1;
61+
let more = 100;
62+
63+
if less < more {
64+
wrap_with(will_be_called(), less < more, |inner| print(" ***", inner, "*** "));
65+
wrap_with(will_be_called(), more < less, |inner| print(" ***", inner, "*** "));
66+
} else {
67+
wrap_with(will_not_be_called(), true, |inner| print("wrapped result is: ", inner, ""));
68+
}
69+
}
70+
71+
// Check for metadata, variables, declarations, and function definitions injected
72+
// into LLVM IR when compiling with -Cinstrument-coverage.
73+
74+
// WINDOWS: $__llvm_profile_runtime_user = comdat any
75+
76+
// CHECK: @__llvm_coverage_mapping = private constant
77+
// CHECK-SAME: section "[[INSTR_PROF_COVMAP]]", align 8
78+
79+
// CHECK: @__covrec_{{[A-F0-9]+}}u = linkonce_odr hidden constant
80+
// CHECK-SAME: section "[[INSTR_PROF_COVFUN]]"[[COMDAT_IF_SUPPORTED]], align 8
81+
82+
// WINDOWS: @__llvm_profile_runtime = external{{.*}}global i32
83+
84+
// CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global
85+
// CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8
86+
87+
// CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog14will_be_called = {{private|internal}} global
88+
// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called
89+
// CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8
90+
91+
// CHECK: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global
92+
// CHECK-SAME: section "[[INSTR_PROF_CNTS]]"{{.*}}, align 8
93+
94+
// CHECK: @__profd__R{{[a-zA-Z0-9_]+}}testprog4main = {{private|internal}} global
95+
// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog4main
96+
// CHECK-SAME: section "[[INSTR_PROF_DATA]]"{{.*}}, align 8
97+
98+
// CHECK: @__llvm_prf_nm = private constant
99+
// CHECK-SAME: section "[[INSTR_PROF_NAME]]", align 1
100+
101+
// CHECK: @llvm.used = appending global
102+
// CHECK-SAME: @__llvm_coverage_mapping
103+
// CHECK-SAME: @__llvm_prf_nm
104+
// CHECK-SAME: section "llvm.metadata"
105+
106+
// CHECK: define internal { {{.*}} } @_R{{[a-zA-Z0-9_]+}}testprog14will_be_called() unnamed_addr #{{[0-9]+}} {
107+
// CHECK-NEXT: start:
108+
// CHECK-NOT: define internal
109+
// CHECK: atomicrmw add ptr
110+
// CHECK-SAME: @__profc__R{{[a-zA-Z0-9_]+}}testprog14will_be_called,
111+
112+
// CHECK: declare void @llvm.instrprof.increment(ptr, i64, i32, i32) #[[LLVM_INSTRPROF_INCREMENT_ATTR:[0-9]+]]
113+
114+
// WINDOWS: define linkonce_odr hidden i32 @__llvm_profile_runtime_user() #[[LLVM_PROFILE_RUNTIME_USER_ATTR:[0-9]+]] comdat {
115+
// WINDOWS-NEXT: %1 = load i32, ptr @__llvm_profile_runtime
116+
// WINDOWS-NEXT: ret i32 %1
117+
// WINDOWS-NEXT: }
118+
119+
// CHECK: attributes #[[LLVM_INSTRPROF_INCREMENT_ATTR]] = { nounwind }
120+
// WINDOWS: attributes #[[LLVM_PROFILE_RUNTIME_USER_ATTR]] = { noinline }
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Simple test that uses the default CHECK prefix and should always succeed.
2+
3+
// CHECK: main
4+
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Arguments provided via `filecheck-flags` should be passed to `filecheck`.
2+
3+
//@ revisions: good bad
4+
//@ [good] filecheck-flags: --check-prefix=CUSTOM
5+
//@ [bad] should-fail
6+
7+
// CUSTOM: main
8+
fn main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This is exactly like `msvc-prefix-good.rs`, except that it should always fail.
2+
3+
//@ should-fail
4+
5+
// MSVC: text that should not match
6+
// NONMSVC: text that should not match
7+
fn main() {}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// One of MSVC or NONMSVC should always be defined, so this test should pass.
2+
3+
// (one of these should always be present)
4+
5+
// MSVC: main
6+
// NONMSVC: main
7+
fn main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// A test that doesn't include any filecheck directives should fail.
2+
3+
//@ should-fail
4+
5+
fn main() {}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// The current revision name is registered as a filecheck prefix.
2+
3+
//@ revisions: GOOD BAD
4+
//@ [BAD] should-fail
5+
6+
// GOOD: main
7+
// BAD: text that should not match
8+
fn main() {}

‎tests/run-make/coverage-llvmir/Makefile

Lines changed: 0 additions & 64 deletions
This file was deleted.

‎tests/run-make/coverage-llvmir/filecheck.testprog.txt

Lines changed: 0 additions & 50 deletions
This file was deleted.

‎tests/run-make/coverage-llvmir/testprog.rs

Lines changed: 0 additions & 38 deletions
This file was deleted.

‎tests/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ pub fn assert_sigpipe_handler(expected_handler: SignalHandler) {
1717
target_os = "android",
1818
)))]
1919
{
20-
let prev = unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) };
20+
let actual = unsafe {
21+
let mut actual: libc::sigaction = std::mem::zeroed();
22+
libc::sigaction(libc::SIGPIPE, std::ptr::null(), &mut actual);
23+
actual.sa_sigaction
24+
};
2125

2226
let expected = match expected_handler {
2327
SignalHandler::Ignore => libc::SIG_IGN,
2428
SignalHandler::Default => libc::SIG_DFL,
2529
};
26-
assert_eq!(prev, expected, "expected sigpipe value matches actual value");
2730

28-
// Unlikely to matter, but restore the old value anyway
29-
unsafe {
30-
libc::signal(libc::SIGPIPE, prev);
31-
};
31+
assert_eq!(actual, expected, "actual and expected SIGPIPE disposition differs");
3232
}
3333
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#![allow(incomplete_features)]
2+
#![feature(non_lifetime_binders)]
3+
4+
trait Foo: for<T> Bar<T> {}
5+
6+
trait Bar<T: ?Sized> {
7+
fn method(&self) {}
8+
}
9+
10+
struct Type2;
11+
fn needs_bar(_: *mut Type2) {}
12+
13+
fn main() {
14+
let x: &dyn Foo = &();
15+
//~^ ERROR the trait `Foo` cannot be made into an object
16+
//~| ERROR the trait `Foo` cannot be made into an object
17+
18+
needs_bar(x);
19+
//~^ ERROR mismatched types
20+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
error[E0038]: the trait `Foo` cannot be made into an object
2+
--> $DIR/span-bug-issue-121597.rs:14:23
3+
|
4+
LL | let x: &dyn Foo = &();
5+
| ^^^ `Foo` cannot be made into an object
6+
|
7+
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
8+
--> $DIR/span-bug-issue-121597.rs:4:12
9+
|
10+
LL | trait Foo: for<T> Bar<T> {}
11+
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
12+
| |
13+
| this trait cannot be made into an object...
14+
= note: required for the cast from `&()` to `&dyn Foo`
15+
16+
error[E0038]: the trait `Foo` cannot be made into an object
17+
--> $DIR/span-bug-issue-121597.rs:14:12
18+
|
19+
LL | let x: &dyn Foo = &();
20+
| ^^^^^^^^ `Foo` cannot be made into an object
21+
|
22+
note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety>
23+
--> $DIR/span-bug-issue-121597.rs:4:12
24+
|
25+
LL | trait Foo: for<T> Bar<T> {}
26+
| --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables
27+
| |
28+
| this trait cannot be made into an object...
29+
30+
error[E0308]: mismatched types
31+
--> $DIR/span-bug-issue-121597.rs:18:15
32+
|
33+
LL | needs_bar(x);
34+
| --------- ^ types differ in mutability
35+
| |
36+
| arguments to this function are incorrect
37+
|
38+
= note: expected raw pointer `*mut Type2`
39+
found reference `&dyn Foo`
40+
note: function defined here
41+
--> $DIR/span-bug-issue-121597.rs:11:4
42+
|
43+
LL | fn needs_bar(_: *mut Type2) {}
44+
| ^^^^^^^^^ -------------
45+
46+
error: aborting due to 3 previous errors
47+
48+
Some errors have detailed explanations: E0038, E0308.
49+
For more information about an error, try `rustc --explain E0038`.

‎tests/ui/lexer/lex-emoji-identifiers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ fn invalid_emoji_usages() {
44
let wireless🛜 = "basic emoji"; //~ ERROR: identifiers cannot contain emoji
55
// FIXME
66
let key1️⃣ = "keycap sequence"; //~ ERROR: unknown start of token
7-
//~^ WARN: identifier contains an uncommon Unicode codepoint
7+
//~^ WARN: identifier contains an uncommon character: '\u{fe0f}'
88
let flag🇺🇳 = "flag sequence"; //~ ERROR: identifiers cannot contain emoji
99
let wales🏴 = "tag sequence"; //~ ERROR: identifiers cannot contain emoji
1010
let folded🙏🏿 = "modifier sequence"; //~ ERROR: identifiers cannot contain emoji

‎tests/ui/lexer/lex-emoji-identifiers.stderr

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ error: identifiers cannot contain emoji: `folded🙏🏿`
4040
LL | let folded🙏🏿 = "modifier sequence";
4141
| ^^^^^^^^^^
4242

43-
warning: identifier contains an uncommon Unicode codepoint: '\u{fe0f}'
43+
warning: identifier contains an uncommon character: '\u{fe0f}'
4444
--> $DIR/lex-emoji-identifiers.rs:6:9
4545
|
4646
LL | let key1️⃣ = "keycap sequence";
4747
| ^^^^
4848
|
49+
= note: this character is included in the Unicode general security profile
4950
= note: `#[warn(uncommon_codepoints)]` on by default
5051

5152
error: aborting due to 7 previous errors; 1 warning emitted
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ edition:2018
2+
3+
#![feature(allocator_api)]
4+
struct Struct;
5+
impl Struct {
6+
async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
7+
//~^ ERROR the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
8+
//~| ERROR Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without
9+
&1
10+
}
11+
}
12+
13+
fn main() {}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0277]: the trait bound `impl FnMut(&mut Self): Allocator` is not satisfied
2+
--> $DIR/could-not-resolve-issue-121503.rs:6:5
3+
|
4+
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Allocator` is not implemented for `impl FnMut(&mut Self)`
6+
|
7+
note: required by a bound in `Box`
8+
--> $SRC_DIR/alloc/src/boxed.rs:LL:COL
9+
help: consider further restricting this bound
10+
|
11+
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self) + std::alloc::Allocator>) -> &u32 {
12+
| +++++++++++++++++++++++
13+
14+
error[E0658]: `Box<Struct, impl FnMut(&mut Self)>` cannot be used as the type of `self` without the `arbitrary_self_types` feature
15+
--> $DIR/could-not-resolve-issue-121503.rs:6:35
16+
|
17+
LL | async fn box_ref_Struct(self: Box<Self, impl FnMut(&mut Self)>) -> &u32 {
18+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
19+
|
20+
= note: see issue #44874 <https://github.com/rust-lang/rust/issues/44874> for more information
21+
= help: add `#![feature(arbitrary_self_types)]` to the crate attributes to enable
22+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
23+
= help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`)
24+
25+
error: aborting due to 2 previous errors
26+
27+
Some errors have detailed explanations: E0277, E0658.
28+
For more information about an error, try `rustc --explain E0277`.

‎tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#![deny(uncommon_codepoints)]
22

3-
const µ: f64 = 0.000001; //~ ERROR identifier contains an uncommon Unicode codepoint
3+
const µ: f64 = 0.000001; //~ identifier contains a non normalized (NFKC) character: 'µ'
44
//~| WARNING should have an upper case name
55

6-
fn dijkstra() {} //~ ERROR identifier contains an uncommon Unicode codepoint
6+
fn dijkstra() {}
7+
//~^ ERROR identifier contains a non normalized (NFKC) character: 'ij'
78

89
fn main() {
9-
let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon Unicode codepoints
10+
let ㇻㇲㇳ = "rust"; //~ ERROR identifier contains uncommon characters: 'ㇻ', 'ㇲ', and 'ㇳ'
1011

1112
// using the same identifier the second time won't trigger the lint.
1213
println!("{}", ㇻㇲㇳ);

‎tests/ui/lint/rfc-2457-non-ascii-idents/lint-uncommon-codepoints.stderr

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
1-
error: identifier contains an uncommon Unicode codepoint: 'µ'
1+
error: identifier contains a non normalized (NFKC) character: 'µ'
22
--> $DIR/lint-uncommon-codepoints.rs:3:7
33
|
44
LL | const µ: f64 = 0.000001;
55
| ^
66
|
7+
= note: this character is included in the Not_NFKC Unicode general security profile
78
note: the lint level is defined here
89
--> $DIR/lint-uncommon-codepoints.rs:1:9
910
|
1011
LL | #![deny(uncommon_codepoints)]
1112
| ^^^^^^^^^^^^^^^^^^^
1213

13-
error: identifier contains an uncommon Unicode codepoint: 'ij'
14+
error: identifier contains a non normalized (NFKC) character: 'ij'
1415
--> $DIR/lint-uncommon-codepoints.rs:6:4
1516
|
1617
LL | fn dijkstra() {}
1718
| ^^^^^^^
19+
|
20+
= note: this character is included in the Not_NFKC Unicode general security profile
1821

19-
error: identifier contains uncommon Unicode codepoints: 'ㇻ', 'ㇲ', and 'ㇳ'
20-
--> $DIR/lint-uncommon-codepoints.rs:9:9
22+
error: identifier contains uncommon characters: 'ㇻ', 'ㇲ', and 'ㇳ'
23+
--> $DIR/lint-uncommon-codepoints.rs:10:9
2124
|
2225
LL | let ㇻㇲㇳ = "rust";
2326
| ^^^^^^
27+
|
28+
= note: these characters are included in the Unicode general security profile
2429

2530
warning: constant `µ` should have an upper case name
2631
--> $DIR/lint-uncommon-codepoints.rs:3:7

0 commit comments

Comments
 (0)
This repository has been archived.