Skip to content

Commit aa65b08

Browse files
committed
Auto merge of rust-lang#86982 - GuillaumeGomez:rollup-7sbye3c, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - rust-lang#84961 (Rework SESSION_GLOBALS API) - rust-lang#86726 (Use diagnostic items instead of lang items for rfc2229 migrations) - rust-lang#86789 (Update BTreeSet::drain_filter documentation) - rust-lang#86838 (Checking that function is const if marked with rustc_const_unstable) - rust-lang#86903 (Fix small headers display) - rust-lang#86913 (Document rustdoc with `--document-private-items`) - rust-lang#86957 (Update .mailmap file) - rust-lang#86971 (mailmap: Add alternative addresses for myself) Failed merges: - rust-lang#86869 (Account for capture kind in auto traits migration) r? `@ghost` `@rustbot` modify labels: rollup
2 parents d0485c7 + 6056682 commit aa65b08

File tree

46 files changed

+412
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+412
-150
lines changed

.mailmap

+4
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,14 @@ Hanna Kruppe <[email protected]> <[email protected]>
113113
114114
115115
Herman J. Radtke III <[email protected]> Herman J. Radtke III <[email protected]>
116+
117+
118+
116119
Ilyong Cho <[email protected]>
117120
inquisitivecrystal <[email protected]>
118121
Ivan Ivaschenko <[email protected]>
119122
J. J. Weber <[email protected]>
123+
120124
Jakub Adam Wieczorek <[email protected]> <[email protected]>
121125
Jakub Adam Wieczorek <[email protected]> <[email protected]>
122126
Jakub Adam Wieczorek <[email protected]> <[email protected]>

compiler/rustc_ast/src/util/comments/tests.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use super::*;
2-
use rustc_span::with_default_session_globals;
2+
use rustc_span::create_default_session_globals_then;
33

44
#[test]
55
fn test_block_doc_comment_1() {
6-
with_default_session_globals(|| {
6+
create_default_session_globals_then(|| {
77
let comment = "\n * Test \n ** Test\n * Test\n";
88
let stripped = beautify_doc_string(Symbol::intern(comment));
99
assert_eq!(stripped.as_str(), " Test \n* Test\n Test");
@@ -12,7 +12,7 @@ fn test_block_doc_comment_1() {
1212

1313
#[test]
1414
fn test_block_doc_comment_2() {
15-
with_default_session_globals(|| {
15+
create_default_session_globals_then(|| {
1616
let comment = "\n * Test\n * Test\n";
1717
let stripped = beautify_doc_string(Symbol::intern(comment));
1818
assert_eq!(stripped.as_str(), " Test\n Test");
@@ -21,7 +21,7 @@ fn test_block_doc_comment_2() {
2121

2222
#[test]
2323
fn test_block_doc_comment_3() {
24-
with_default_session_globals(|| {
24+
create_default_session_globals_then(|| {
2525
let comment = "\n let a: *i32;\n *a = 5;\n";
2626
let stripped = beautify_doc_string(Symbol::intern(comment));
2727
assert_eq!(stripped.as_str(), " let a: *i32;\n *a = 5;");
@@ -30,7 +30,7 @@ fn test_block_doc_comment_3() {
3030

3131
#[test]
3232
fn test_line_doc_comment() {
33-
with_default_session_globals(|| {
33+
create_default_session_globals_then(|| {
3434
let stripped = beautify_doc_string(Symbol::intern(" test"));
3535
assert_eq!(stripped.as_str(), " test");
3636
let stripped = beautify_doc_string(Symbol::intern("! test"));

compiler/rustc_ast_pretty/src/pprust/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use super::*;
22

33
use rustc_ast as ast;
4+
use rustc_span::create_default_session_globals_then;
45
use rustc_span::symbol::Ident;
5-
use rustc_span::with_default_session_globals;
66

77
fn fun_to_string(
88
decl: &ast::FnDecl,
@@ -24,7 +24,7 @@ fn variant_to_string(var: &ast::Variant) -> String {
2424

2525
#[test]
2626
fn test_fun_to_string() {
27-
with_default_session_globals(|| {
27+
create_default_session_globals_then(|| {
2828
let abba_ident = Ident::from_str("abba");
2929

3030
let decl =
@@ -39,7 +39,7 @@ fn test_fun_to_string() {
3939

4040
#[test]
4141
fn test_variant_to_string() {
42-
with_default_session_globals(|| {
42+
create_default_session_globals_then(|| {
4343
let ident = Ident::from_str("principal_skinner");
4444

4545
let var = ast::Variant {

compiler/rustc_error_codes/src/error_codes/E0542.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Erroneous code example:
1010
fn _stable_fn() {}
1111
1212
#[rustc_const_stable(feature = "_stable_const_fn")] // invalid
13-
fn _stable_const_fn() {}
13+
const fn _stable_const_fn() {}
1414
1515
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
1616
#[rustc_deprecated(
@@ -29,7 +29,7 @@ To fix this issue, you need to provide the `since` field. Example:
2929
fn _stable_fn() {}
3030
3131
#[rustc_const_stable(feature = "_stable_const_fn", since = "1.0.0")] // ok!
32-
fn _stable_const_fn() {}
32+
const fn _stable_const_fn() {}
3333
3434
#[stable(feature = "_deprecated_fn", since = "0.1.0")]
3535
#[rustc_deprecated(

compiler/rustc_error_codes/src/error_codes/E0545.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Erroneous code example:
1010
fn _unstable_fn() {}
1111
1212
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "0")] // invalid
13-
fn _unstable_const_fn() {}
13+
const fn _unstable_const_fn() {}
1414
```
1515

1616
To fix this issue, you need to provide a correct value in the `issue` field.
@@ -24,7 +24,7 @@ Example:
2424
fn _unstable_fn() {}
2525
2626
#[rustc_const_unstable(feature = "_unstable_const_fn", issue = "1")] // ok!
27-
fn _unstable_const_fn() {}
27+
const fn _unstable_const_fn() {}
2828
```
2929

3030
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix

compiler/rustc_error_codes/src/error_codes/E0547.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Erroneous code example:
1010
fn _unstable_fn() {}
1111
1212
#[rustc_const_unstable(feature = "_unstable_const_fn")] // invalid
13-
fn _unstable_const_fn() {}
13+
const fn _unstable_const_fn() {}
1414
```
1515

1616
To fix this issue, you need to provide the `issue` field. Example:
@@ -26,7 +26,7 @@ fn _unstable_fn() {}
2626
feature = "_unstable_const_fn",
2727
issue = "none"
2828
)] // ok!
29-
fn _unstable_const_fn() {}
29+
const fn _unstable_const_fn() {}
3030
```
3131

3232
See the [How Rust is Made and “Nightly Rust”][how-rust-made-nightly] appendix

compiler/rustc_errors/src/json/tests.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,11 @@ impl<T: Write> Write for Shared<T> {
3939
}
4040
}
4141

42-
fn with_default_session_globals(f: impl FnOnce()) {
43-
let session_globals = rustc_span::SessionGlobals::new(rustc_span::edition::DEFAULT_EDITION);
44-
rustc_span::SESSION_GLOBALS.set(&session_globals, f);
45-
}
46-
4742
/// Test the span yields correct positions in JSON.
4843
fn test_positions(code: &str, span: (u32, u32), expected_output: SpanTestData) {
4944
let expected_output = TestData { spans: vec![expected_output] };
5045

51-
with_default_session_globals(|| {
46+
rustc_span::create_default_session_globals_then(|| {
5247
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
5348
sm.new_source_file(Path::new("test.rs").to_owned().into(), code.to_owned());
5449

compiler/rustc_expand/src/mut_visit/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use crate::tests::{matches_codepattern, string_to_crate};
33
use rustc_ast as ast;
44
use rustc_ast::mut_visit::MutVisitor;
55
use rustc_ast_pretty::pprust;
6+
use rustc_span::create_default_session_globals_then;
67
use rustc_span::symbol::Ident;
7-
use rustc_span::with_default_session_globals;
88

99
// This version doesn't care about getting comments or doc-strings in.
1010
fn print_crate_items(krate: &ast::Crate) -> String {
@@ -38,7 +38,7 @@ macro_rules! assert_pred {
3838
// Make sure idents get transformed everywhere.
3939
#[test]
4040
fn ident_transformation() {
41-
with_default_session_globals(|| {
41+
create_default_session_globals_then(|| {
4242
let mut zz_visitor = ToZzIdentMutVisitor;
4343
let mut krate =
4444
string_to_crate("#[a] mod b {fn c (d : e, f : g) {h!(i,j,k);l;m}}".to_string());
@@ -55,7 +55,7 @@ fn ident_transformation() {
5555
// Make sure idents get transformed even inside macro defs.
5656
#[test]
5757
fn ident_transformation_in_defs() {
58-
with_default_session_globals(|| {
58+
create_default_session_globals_then(|| {
5959
let mut zz_visitor = ToZzIdentMutVisitor;
6060
let mut krate = string_to_crate(
6161
"macro_rules! a {(b $c:expr $(d $e:token)f+ => \

compiler/rustc_expand/src/parse/tests.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ use rustc_errors::PResult;
1010
use rustc_parse::new_parser_from_source_str;
1111
use rustc_parse::parser::ForceCollect;
1212
use rustc_session::parse::ParseSess;
13+
use rustc_span::create_default_session_globals_then;
1314
use rustc_span::source_map::FilePathMapping;
1415
use rustc_span::symbol::{kw, sym, Symbol};
15-
use rustc_span::with_default_session_globals;
1616
use rustc_span::{BytePos, FileName, Pos, Span};
1717

1818
use std::path::PathBuf;
@@ -51,15 +51,15 @@ fn string_to_item(source_str: String) -> Option<P<ast::Item>> {
5151
#[should_panic]
5252
#[test]
5353
fn bad_path_expr_1() {
54-
with_default_session_globals(|| {
54+
create_default_session_globals_then(|| {
5555
string_to_expr("::abc::def::return".to_string());
5656
})
5757
}
5858

5959
// Checks the token-tree-ization of macros.
6060
#[test]
6161
fn string_to_tts_macro() {
62-
with_default_session_globals(|| {
62+
create_default_session_globals_then(|| {
6363
let tts: Vec<_> =
6464
string_to_stream("macro_rules! zip (($a)=>($a))".to_string()).trees().collect();
6565
let tts: &[TokenTree] = &tts[..];
@@ -96,7 +96,7 @@ fn string_to_tts_macro() {
9696

9797
#[test]
9898
fn string_to_tts_1() {
99-
with_default_session_globals(|| {
99+
create_default_session_globals_then(|| {
100100
let tts = string_to_stream("fn a (b : i32) { b; }".to_string());
101101

102102
let expected = TokenStream::new(vec![
@@ -131,7 +131,7 @@ fn string_to_tts_1() {
131131

132132
#[test]
133133
fn parse_use() {
134-
with_default_session_globals(|| {
134+
create_default_session_globals_then(|| {
135135
let use_s = "use foo::bar::baz;";
136136
let vitem = string_to_item(use_s.to_string()).unwrap();
137137
let vitem_s = item_to_string(&vitem);
@@ -146,7 +146,7 @@ fn parse_use() {
146146

147147
#[test]
148148
fn parse_extern_crate() {
149-
with_default_session_globals(|| {
149+
create_default_session_globals_then(|| {
150150
let ex_s = "extern crate foo;";
151151
let vitem = string_to_item(ex_s.to_string()).unwrap();
152152
let vitem_s = item_to_string(&vitem);
@@ -184,7 +184,7 @@ fn get_spans_of_pat_idents(src: &str) -> Vec<Span> {
184184

185185
#[test]
186186
fn span_of_self_arg_pat_idents_are_correct() {
187-
with_default_session_globals(|| {
187+
create_default_session_globals_then(|| {
188188
let srcs = [
189189
"impl z { fn a (&self, &myarg: i32) {} }",
190190
"impl z { fn a (&mut self, &myarg: i32) {} }",
@@ -208,7 +208,7 @@ fn span_of_self_arg_pat_idents_are_correct() {
208208

209209
#[test]
210210
fn parse_exprs() {
211-
with_default_session_globals(|| {
211+
create_default_session_globals_then(|| {
212212
// just make sure that they parse....
213213
string_to_expr("3 + 4".to_string());
214214
string_to_expr("a::z.froob(b,&(987+3))".to_string());
@@ -217,7 +217,7 @@ fn parse_exprs() {
217217

218218
#[test]
219219
fn attrs_fix_bug() {
220-
with_default_session_globals(|| {
220+
create_default_session_globals_then(|| {
221221
string_to_item(
222222
"pub fn mk_file_writer(path: &Path, flags: &[FileFlag])
223223
-> Result<Box<Writer>, String> {
@@ -238,7 +238,7 @@ let mut fflags: c_int = wb();
238238

239239
#[test]
240240
fn crlf_doc_comments() {
241-
with_default_session_globals(|| {
241+
create_default_session_globals_then(|| {
242242
let sess = sess();
243243

244244
let name_1 = FileName::Custom("crlf_source_1".to_string());
@@ -272,7 +272,7 @@ fn ttdelim_span() {
272272
new_parser_from_source_str(sess, name, source).parse_expr()
273273
}
274274

275-
with_default_session_globals(|| {
275+
create_default_session_globals_then(|| {
276276
let sess = sess();
277277
let expr = parse_expr_from_source_str(
278278
PathBuf::from("foo").into(),
@@ -300,7 +300,7 @@ fn ttdelim_span() {
300300
// See `recurse_into_file_modules` in the parser.
301301
#[test]
302302
fn out_of_line_mod() {
303-
with_default_session_globals(|| {
303+
create_default_session_globals_then(|| {
304304
let item = parse_item_from_source_str(
305305
PathBuf::from("foo").into(),
306306
"mod foo { struct S; mod this_does_not_exist; }".to_owned(),

compiler/rustc_expand/src/tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ use rustc_ast as ast;
22
use rustc_ast::tokenstream::TokenStream;
33
use rustc_parse::{new_parser_from_source_str, parser::Parser, source_file_to_stream};
44
use rustc_session::parse::ParseSess;
5+
use rustc_span::create_default_session_if_not_set_then;
56
use rustc_span::source_map::{FilePathMapping, SourceMap};
6-
use rustc_span::with_default_session_globals;
77
use rustc_span::{BytePos, MultiSpan, Span};
88

99
use rustc_data_structures::sync::Lrc;
@@ -124,7 +124,7 @@ impl<T: Write> Write for Shared<T> {
124124
}
125125

126126
fn test_harness(file_text: &str, span_labels: Vec<SpanLabel>, expected_output: &str) {
127-
with_default_session_globals(|| {
127+
create_default_session_if_not_set_then(|_| {
128128
let output = Arc::new(Mutex::new(Vec::new()));
129129

130130
let source_map = Lrc::new(SourceMap::new(FilePathMapping::empty()));

0 commit comments

Comments
 (0)