Skip to content

Commit 542febd

Browse files
committed
Auto merge of #103290 - matthiaskrgr:rollup-ngozai3, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #103197 (Stabilize proc_macro::Span::source_text) - #103251 (Fix item declaration highlighting) - #103262 (Adjusting test to needs-unwind, with linking issue) - #103268 (rustdoc: remove no-op CSS `nav.sub { font-size: 1rem }`) - #103272 (Remove extra spaces in docs) - #103276 (Erase regions before checking for `Default` in uninitialized binding error) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 53728ff + e29ecb7 commit 542febd

File tree

10 files changed

+191
-38
lines changed

10 files changed

+191
-38
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,17 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
492492
let Some(default_trait) = tcx.get_diagnostic_item(sym::Default) else {
493493
return false;
494494
};
495+
// Regions are already solved, so we must use a fresh InferCtxt,
496+
// but the type has region variables, so erase those.
495497
tcx.infer_ctxt()
496498
.build()
497-
.type_implements_trait(default_trait, ty, ty::List::empty(), param_env)
498-
.may_apply()
499+
.type_implements_trait(
500+
default_trait,
501+
tcx.erase_regions(ty),
502+
ty::List::empty(),
503+
param_env,
504+
)
505+
.must_apply_modulo_regions()
499506
};
500507

501508
let assign_value = match ty.kind() {

library/core/src/sync/atomic.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ impl AtomicBool {
294294
/// ```
295295
/// use std::sync::atomic::AtomicBool;
296296
///
297-
/// let atomic_true = AtomicBool::new(true);
297+
/// let atomic_true = AtomicBool::new(true);
298298
/// let atomic_false = AtomicBool::new(false);
299299
/// ```
300300
#[inline]
@@ -1179,7 +1179,7 @@ impl<T> AtomicPtr<T> {
11791179
/// use std::sync::atomic::{AtomicPtr, Ordering};
11801180
///
11811181
/// let ptr = &mut 5;
1182-
/// let some_ptr = AtomicPtr::new(ptr);
1182+
/// let some_ptr = AtomicPtr::new(ptr);
11831183
///
11841184
/// let value = some_ptr.load(Ordering::Relaxed);
11851185
/// ```
@@ -1206,7 +1206,7 @@ impl<T> AtomicPtr<T> {
12061206
/// use std::sync::atomic::{AtomicPtr, Ordering};
12071207
///
12081208
/// let ptr = &mut 5;
1209-
/// let some_ptr = AtomicPtr::new(ptr);
1209+
/// let some_ptr = AtomicPtr::new(ptr);
12101210
///
12111211
/// let other_ptr = &mut 10;
12121212
///
@@ -1238,7 +1238,7 @@ impl<T> AtomicPtr<T> {
12381238
/// use std::sync::atomic::{AtomicPtr, Ordering};
12391239
///
12401240
/// let ptr = &mut 5;
1241-
/// let some_ptr = AtomicPtr::new(ptr);
1241+
/// let some_ptr = AtomicPtr::new(ptr);
12421242
///
12431243
/// let other_ptr = &mut 10;
12441244
///
@@ -1290,9 +1290,9 @@ impl<T> AtomicPtr<T> {
12901290
/// use std::sync::atomic::{AtomicPtr, Ordering};
12911291
///
12921292
/// let ptr = &mut 5;
1293-
/// let some_ptr = AtomicPtr::new(ptr);
1293+
/// let some_ptr = AtomicPtr::new(ptr);
12941294
///
1295-
/// let other_ptr = &mut 10;
1295+
/// let other_ptr = &mut 10;
12961296
///
12971297
/// let value = some_ptr.compare_and_swap(ptr, other_ptr, Ordering::Relaxed);
12981298
/// ```
@@ -1333,9 +1333,9 @@ impl<T> AtomicPtr<T> {
13331333
/// use std::sync::atomic::{AtomicPtr, Ordering};
13341334
///
13351335
/// let ptr = &mut 5;
1336-
/// let some_ptr = AtomicPtr::new(ptr);
1336+
/// let some_ptr = AtomicPtr::new(ptr);
13371337
///
1338-
/// let other_ptr = &mut 10;
1338+
/// let other_ptr = &mut 10;
13391339
///
13401340
/// let value = some_ptr.compare_exchange(ptr, other_ptr,
13411341
/// Ordering::SeqCst, Ordering::Relaxed);

library/proc_macro/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ impl Span {
546546
/// Note: The observable result of a macro should only rely on the tokens and
547547
/// not on this source text. The result of this function is a best effort to
548548
/// be used for diagnostics only.
549-
#[unstable(feature = "proc_macro_span", issue = "54725")]
549+
#[stable(feature = "proc_macro_source_text", since = "CURRENT_RUSTC_VERSION")]
550550
pub fn source_text(&self) -> Option<String> {
551551
self.0.source_text()
552552
}

src/librustdoc/html/static/css/rustdoc.css

+20-21
Original file line numberDiff line numberDiff line change
@@ -229,44 +229,44 @@ h1 a,
229229
color: var(--main-color);
230230
}
231231

232-
span.enum, a.enum,
233-
span.struct, a.struct,
234-
span.union, a.union,
235-
span.primitive, a.primitive,
236-
span.type, a.type,
237-
span.foreigntype, a.foreigntype {
232+
.content span.enum, .content a.enum,
233+
.content span.struct, .content a.struct,
234+
.content span.union, .content a.union,
235+
.content span.primitive, .content a.primitive,
236+
.content span.type, .content a.type,
237+
.content span.foreigntype, .content a.foreigntype {
238238
color: var(--type-link-color);
239239
}
240240

241-
span.trait, a.trait,
242-
span.traitalias, a.traitalias {
241+
.content span.trait, .content a.trait,
242+
.content span.traitalias, .content a.traitalias {
243243
color: var(--trait-link-color);
244244
}
245245

246-
span.associatedtype, a.associatedtype,
247-
span.constant, a.constant,
248-
span.static, a.static {
246+
.content span.associatedtype, .content a.associatedtype,
247+
.content span.constant, .content a.constant,
248+
.content span.static, .content a.static {
249249
color: var(--assoc-item-link-color);
250250
}
251251

252-
span.fn, a.fn,
253-
.fnname,
254-
span.method, a.method,
255-
span.tymethod, a.tymethod {
252+
.content span.fn, .content a.fn,
253+
.content .fnname,
254+
.content span.method, .content a.method,
255+
.content span.tymethod, .content a.tymethod {
256256
color: var(--function-link-color);
257257
}
258258

259-
span.attr, a.attr,
260-
span.derive, a.derive,
261-
span.macro, a.macro {
259+
.content span.attr, .content a.attr,
260+
.content span.derive, .content a.derive,
261+
.content span.macro, .content a.macro {
262262
color: var(--macro-link-color);
263263
}
264264

265-
span.mod, a.mod {
265+
.content span.mod, .content a.mod {
266266
color: var(--mod-link-color);
267267
}
268268

269-
span.keyword, a.keyword {
269+
.content span.keyword, .content a.keyword {
270270
color: var(--keyword-link-color);
271271
}
272272

@@ -697,7 +697,6 @@ pre, .rustdoc.source .example-wrap {
697697

698698
nav.sub {
699699
position: relative;
700-
font-size: 1rem;
701700
flex-grow: 1;
702701
margin-bottom: 25px;
703702
}
+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// This test ensures that the color of the items in the type decl are working as expected.
2+
define-function: (
3+
"check-colors",
4+
(
5+
theme,
6+
attr_color,
7+
trait_color,
8+
struct_color,
9+
enum_color,
10+
primitive_color,
11+
constant_color,
12+
fn_color,
13+
assoc_type_color,
14+
),
15+
[
16+
("goto", "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"),
17+
("show-text", true),
18+
("local-storage", {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}),
19+
("reload"),
20+
("assert-css", (".item-decl .code-attribute", {"color": |attr_color|}, ALL)),
21+
("assert-css", (".item-decl .trait", {"color": |trait_color|}, ALL)),
22+
// We need to add `code` here because otherwise it would select the parent too.
23+
("assert-css", (".item-decl code .struct", {"color": |struct_color|}, ALL)),
24+
("assert-css", (".item-decl .enum", {"color": |enum_color|}, ALL)),
25+
("assert-css", (".item-decl .primitive", {"color": |primitive_color|}, ALL)),
26+
("goto", "file://" + |DOC_PATH| + "/test_docs/trait.TraitWithoutGenerics.html"),
27+
("assert-css", (".item-decl .constant", {"color": |constant_color|}, ALL)),
28+
("assert-css", (".item-decl .fnname", {"color": |fn_color|}, ALL)),
29+
("assert-css", (".item-decl .associatedtype", {"color": |assoc_type_color|}, ALL)),
30+
],
31+
)
32+
33+
call-function: (
34+
"check-colors",
35+
{
36+
"theme": "ayu",
37+
"attr_color": "rgb(153, 153, 153)",
38+
"trait_color": "rgb(57, 175, 215)",
39+
"struct_color": "rgb(255, 160, 165)",
40+
"enum_color": "rgb(255, 160, 165)",
41+
"primitive_color": "rgb(255, 160, 165)",
42+
"constant_color": "rgb(57, 175, 215)",
43+
"fn_color": "rgb(253, 214, 135)",
44+
"assoc_type_color": "rgb(57, 175, 215)",
45+
},
46+
)
47+
call-function: (
48+
"check-colors",
49+
{
50+
"theme": "dark",
51+
"attr_color": "rgb(153, 153, 153)",
52+
"trait_color": "rgb(183, 140, 242)",
53+
"struct_color": "rgb(45, 191, 184)",
54+
"enum_color": "rgb(45, 191, 184)",
55+
"primitive_color": "rgb(45, 191, 184)",
56+
"constant_color": "rgb(210, 153, 29)",
57+
"fn_color": "rgb(43, 171, 99)",
58+
"assoc_type_color": "rgb(210, 153, 29)",
59+
},
60+
)
61+
call-function: (
62+
"check-colors",
63+
{
64+
"theme": "light",
65+
"attr_color": "rgb(153, 153, 153)",
66+
"trait_color": "rgb(110, 79, 201)",
67+
"struct_color": "rgb(173, 55, 138)",
68+
"enum_color": "rgb(173, 55, 138)",
69+
"primitive_color": "rgb(173, 55, 138)",
70+
"constant_color": "rgb(56, 115, 173)",
71+
"fn_color": "rgb(173, 124, 55)",
72+
"assoc_type_color": "rgb(56, 115, 173)",
73+
},
74+
)

src/test/rustdoc-gui/sidebar.goml

+6-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ assert-text: (".sidebar-elems section ul > li:nth-child(2)", "Modules")
2020
assert-text: (".sidebar-elems section ul > li:nth-child(3)", "Macros")
2121
assert-text: (".sidebar-elems section ul > li:nth-child(4)", "Structs")
2222
assert-text: (".sidebar-elems section ul > li:nth-child(5)", "Enums")
23-
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Traits")
24-
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Functions")
25-
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Type Definitions")
26-
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Unions")
27-
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Keywords")
23+
assert-text: (".sidebar-elems section ul > li:nth-child(6)", "Constants")
24+
assert-text: (".sidebar-elems section ul > li:nth-child(7)", "Traits")
25+
assert-text: (".sidebar-elems section ul > li:nth-child(8)", "Functions")
26+
assert-text: (".sidebar-elems section ul > li:nth-child(9)", "Type Definitions")
27+
assert-text: (".sidebar-elems section ul > li:nth-child(10)", "Unions")
28+
assert-text: (".sidebar-elems section ul > li:nth-child(11)", "Keywords")
2829
assert-text: ("#structs + .item-table .item-left > a", "Foo")
2930
click: "#structs + .item-table .item-left > a"
3031

src/test/rustdoc-gui/src/test_docs/lib.rs

+18
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![crate_name = "test_docs"]
66
#![feature(rustdoc_internals)]
77
#![feature(doc_cfg)]
8+
#![feature(associated_type_defaults)]
89

910
/*!
1011
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
@@ -386,3 +387,20 @@ impl TypeWithNoDocblocks {
386387
pub unsafe fn unsafe_fn() {}
387388

388389
pub fn safe_fn() {}
390+
391+
#[repr(C)]
392+
pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> {
393+
s: S,
394+
t: T,
395+
e: E,
396+
p: P,
397+
}
398+
399+
pub const CONST: u8 = 0;
400+
401+
pub trait TraitWithoutGenerics {
402+
const C: u8 = CONST;
403+
type T = SomeType;
404+
405+
fn foo();
406+
}

src/test/ui/borrowck/issue-103250.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// edition:2021
2+
3+
type TranslateFn = Box<dyn Fn(String, String) -> String>;
4+
5+
pub struct DeviceCluster {
6+
devices: Vec<Device>,
7+
}
8+
9+
impl DeviceCluster {
10+
pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> {
11+
let mut last_error: Box<dyn std::error::Error>;
12+
13+
for device in &mut self.devices {
14+
match device.do_something().await {
15+
Ok(info) => {
16+
return Ok(info);
17+
}
18+
Err(e) => {}
19+
}
20+
}
21+
22+
Err(last_error)
23+
//~^ ERROR used binding `last_error` isn't initialized
24+
}
25+
}
26+
27+
pub struct Device {
28+
translate_fn: Option<TranslateFn>,
29+
}
30+
31+
impl Device {
32+
pub async fn do_something(&mut self) -> Result<String, Box<dyn std::error::Error>> {
33+
Ok(String::from(""))
34+
}
35+
}
36+
37+
fn main() {}
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0381]: used binding `last_error` isn't initialized
2+
--> $DIR/issue-103250.rs:22:13
3+
|
4+
LL | let mut last_error: Box<dyn std::error::Error>;
5+
| -------------- binding declared here but left uninitialized
6+
...
7+
LL | Err(last_error)
8+
| ^^^^^^^^^^ `last_error` used here but it isn't initialized
9+
|
10+
help: consider assigning a value
11+
|
12+
LL | let mut last_error: Box<dyn std::error::Error> = todo!();
13+
| +++++++++
14+
15+
error: aborting due to previous error
16+
17+
For more information about this error, try `rustc --explain E0381`.

src/test/ui/test-attrs/test-fn-signature-verification-for-explicit-return-type.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// run-pass
2-
// ignore-fuchsia Test must be run out-of-process
2+
// needs-unwind (#73509)
33

44
#![feature(test)]
55

0 commit comments

Comments
 (0)