Skip to content

Commit dd8c3a8

Browse files
committed
Auto merge of #102691 - notriddle:rollup-tdtyagp, r=notriddle
Rollup of 5 pull requests Successful merges: - #102574 (Make Hash{Set,Map}::with_hasher unstably const) - #102650 (Slightly improve no return for returning function error) - #102662 (rustdoc: remove no-op CSS `.code-header { display: block }`) - #102670 (follow-up fix about 101866 to print the self type.) - #102686 (Don't build the compiler before building rls) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents d8613f7 + 40ce4af commit dd8c3a8

24 files changed

+52
-42
lines changed

compiler/rustc_hir_analysis/src/check/fn_ctxt/suggestions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11231123
} else {
11241124
err.span_suggestion_short(
11251125
span_semi,
1126-
"remove this semicolon",
1126+
"remove this semicolon to return this value",
11271127
"",
11281128
Applicability::MachineApplicable,
11291129
);

compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2265,7 +2265,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
22652265
};
22662266
let mut suggestions = vec![(
22672267
trait_path_segment.ident.span.shrink_to_lo(),
2268-
format!("<{} as ", self.tcx.def_path(impl_def_id).to_string_no_crate_verbose())
2268+
format!("<{} as ", self.tcx.type_of(impl_def_id))
22692269
)];
22702270
if let Some(generic_arg) = trait_path_segment.args {
22712271
let between_span = trait_path_segment.ident.span.between(generic_arg.span_ext);

library/std/src/collections/hash/map.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ impl<K, V, S> HashMap<K, V, S> {
280280
/// ```
281281
#[inline]
282282
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
283-
pub fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
283+
#[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")]
284+
pub const fn with_hasher(hash_builder: S) -> HashMap<K, V, S> {
284285
HashMap { base: base::HashMap::with_hasher(hash_builder) }
285286
}
286287

library/std/src/collections/hash/map/tests.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1115,3 +1115,9 @@ fn from_array() {
11151115
// that's a problem!
11161116
let _must_not_require_type_annotation = HashMap::from([(1, 2)]);
11171117
}
1118+
1119+
#[test]
1120+
fn const_with_hasher() {
1121+
const X: HashMap<(), (), ()> = HashMap::with_hasher(());
1122+
assert_eq!(X.len(), 0);
1123+
}

library/std/src/collections/hash/set.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,8 @@ impl<T, S> HashSet<T, S> {
376376
/// ```
377377
#[inline]
378378
#[stable(feature = "hashmap_build_hasher", since = "1.7.0")]
379-
pub fn with_hasher(hasher: S) -> HashSet<T, S> {
379+
#[rustc_const_unstable(feature = "const_collections_with_hasher", issue = "102575")]
380+
pub const fn with_hasher(hasher: S) -> HashSet<T, S> {
380381
HashSet { base: base::HashSet::with_hasher(hasher) }
381382
}
382383

library/std/src/collections/hash/set/tests.rs

+6
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,9 @@ fn from_array() {
496496
// that's a problem!
497497
let _must_not_require_type_annotation = HashSet::from([1, 2]);
498498
}
499+
500+
#[test]
501+
fn const_with_hasher() {
502+
const X: HashSet<(), ()> = HashSet::with_hasher(());
503+
assert_eq!(X.len(), 0);
504+
}

library/std/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@
351351
// Only used in tests/benchmarks:
352352
//
353353
// Only for const-ness:
354+
#![feature(const_collections_with_hasher)]
354355
#![feature(const_io_structs)]
355356
#![feature(const_ip)]
356357
#![feature(const_ipv4)]

src/bootstrap/tool.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -870,10 +870,10 @@ tool_extended!((self, builder),
870870
Clippy, "src/tools/clippy", "clippy-driver", stable=true, in_tree=true, {};
871871
Miri, "src/tools/miri", "miri", stable=false, in_tree=true, {};
872872
CargoMiri, "src/tools/miri/cargo-miri", "cargo-miri", stable=false, in_tree=true, {};
873-
Rls, "src/tools/rls", "rls", stable=true, {};
874873
// FIXME: tool_std is not quite right, we shouldn't allow nightly features.
875874
// But `builder.cargo` doesn't know how to handle ToolBootstrap in stages other than 0,
876875
// and this is close enough for now.
876+
Rls, "src/tools/rls", "rls", stable=true, in_tree=true, tool_std=true, {};
877877
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, in_tree=true, tool_std=true, {};
878878
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, in_tree=true, {};
879879
);

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

-4
Original file line numberDiff line numberDiff line change
@@ -654,10 +654,6 @@ pre.example-line-numbers {
654654
font-weight: normal;
655655
}
656656

657-
.method > .code-header, .trait-impl > .code-header {
658-
display: block;
659-
}
660-
661657
.in-band {
662658
flex-grow: 1;
663659
margin: 0px;

src/test/ui/block-result/consider-removing-last-semi.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | pub fn f() -> String {
77
| implicitly returns `()` as its body has no tail or `return` expression
88
LL | 0u8;
99
LL | "bla".to_string();
10-
| - help: remove this semicolon
10+
| - help: remove this semicolon to return this value
1111

1212
error[E0308]: mismatched types
1313
--> $DIR/consider-removing-last-semi.rs:8:15
@@ -18,7 +18,7 @@ LL | pub fn g() -> String {
1818
| implicitly returns `()` as its body has no tail or `return` expression
1919
LL | "this won't work".to_string();
2020
LL | "removeme".to_string();
21-
| - help: remove this semicolon
21+
| - help: remove this semicolon to return this value
2222

2323
error[E0308]: mismatched types
2424
--> $DIR/consider-removing-last-semi.rs:13:25
@@ -29,7 +29,7 @@ LL | pub fn macro_tests() -> u32 {
2929
| implicitly returns `()` as its body has no tail or `return` expression
3030
...
3131
LL | mac!();
32-
| - help: remove this semicolon
32+
| - help: remove this semicolon to return this value
3333

3434
error: aborting due to 3 previous errors
3535

src/test/ui/block-result/issue-11714.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn blah() -> i32 {
77
| implicitly returns `()` as its body has no tail or `return` expression
88
...
99
LL | ;
10-
| - help: remove this semicolon
10+
| - help: remove this semicolon to return this value
1111

1212
error: aborting due to previous error
1313

src/test/ui/block-result/issue-13428.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ LL | fn bar() -> String {
1515
| implicitly returns `()` as its body has no tail or `return` expression
1616
LL | "foobar".to_string()
1717
LL | ;
18-
| - help: remove this semicolon
18+
| - help: remove this semicolon to return this value
1919

2020
error: aborting due to 2 previous errors
2121

src/test/ui/closures/old-closure-expression-remove-semicolon.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn foo() -> i32 {
77
fn main() {
88
let _x: i32 = {
99
//~^ ERROR mismatched types
10-
foo() //~ HELP remove this semicolon
10+
foo() //~ HELP remove this semicolon to return this value
1111
};
1212
}

src/test/ui/closures/old-closure-expression-remove-semicolon.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ fn foo() -> i32 {
77
fn main() {
88
let _x: i32 = {
99
//~^ ERROR mismatched types
10-
foo(); //~ HELP remove this semicolon
10+
foo(); //~ HELP remove this semicolon to return this value
1111
};
1212
}

src/test/ui/closures/old-closure-expression-remove-semicolon.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | let _x: i32 = {
55
| ___________________^
66
LL | |
77
LL | | foo();
8-
| | - help: remove this semicolon
8+
| | - help: remove this semicolon to return this value
99
LL | | };
1010
| |_____^ expected `i32`, found `()`
1111

src/test/ui/coercion/coercion-missing-tail-expected-type.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn plus_one(x: i32) -> i32 {
66
| |
77
| implicitly returns `()` as its body has no tail or `return` expression
88
LL | x + 1;
9-
| - help: remove this semicolon
9+
| - help: remove this semicolon to return this value
1010

1111
error[E0308]: mismatched types
1212
--> $DIR/coercion-missing-tail-expected-type.rs:8:13
@@ -16,7 +16,7 @@ LL | fn foo() -> Result<u8, u64> {
1616
| |
1717
| implicitly returns `()` as its body has no tail or `return` expression
1818
LL | Ok(1);
19-
| - help: remove this semicolon
19+
| - help: remove this semicolon to return this value
2020
|
2121
= note: expected enum `Result<u8, u64>`
2222
found unit type `()`

src/test/ui/error-codes/E0283.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | let cont: u32 = Generator::create();
99
|
1010
help: use a fully-qualified path to a specific available implementation (2 found)
1111
|
12-
LL | let cont: u32 = <::Impl as Generator>::create();
13-
| ++++++++++ +
12+
LL | let cont: u32 = <Impl as Generator>::create();
13+
| ++++++++ +
1414

1515
error[E0283]: type annotations needed
1616
--> $DIR/E0283.rs:35:24

src/test/ui/error-codes/E0790.stderr

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | MyTrait::my_fn();
99
|
1010
help: use the fully-qualified path to the only available implementation
1111
|
12-
LL | <::inner::MyStruct as MyTrait>::my_fn();
13-
| +++++++++++++++++++++ +
12+
LL | <MyStruct as MyTrait>::my_fn();
13+
| ++++++++++++ +
1414

1515
error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
1616
--> $DIR/E0790.rs:21:17
@@ -23,8 +23,8 @@ LL | let _ = MyTrait::MY_ASSOC_CONST;
2323
|
2424
help: use the fully-qualified path to the only available implementation
2525
|
26-
LL | let _ = <::inner::MyStruct as MyTrait>::MY_ASSOC_CONST;
27-
| +++++++++++++++++++++ +
26+
LL | let _ = <MyStruct as MyTrait>::MY_ASSOC_CONST;
27+
| ++++++++++++ +
2828

2929
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
3030
--> $DIR/E0790.rs:26:5
@@ -37,8 +37,8 @@ LL | inner::MyTrait::my_fn();
3737
|
3838
help: use the fully-qualified path to the only available implementation
3939
|
40-
LL | inner::<::inner::MyStruct as MyTrait>::my_fn();
41-
| +++++++++++++++++++++ +
40+
LL | inner::<MyStruct as MyTrait>::my_fn();
41+
| ++++++++++++ +
4242

4343
error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type
4444
--> $DIR/E0790.rs:30:13
@@ -51,8 +51,8 @@ LL | let _ = inner::MyTrait::MY_ASSOC_CONST;
5151
|
5252
help: use the fully-qualified path to the only available implementation
5353
|
54-
LL | let _ = inner::<::inner::MyStruct as MyTrait>::MY_ASSOC_CONST;
55-
| +++++++++++++++++++++ +
54+
LL | let _ = inner::<MyStruct as MyTrait>::MY_ASSOC_CONST;
55+
| ++++++++++++ +
5656

5757
error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type
5858
--> $DIR/E0790.rs:50:5
@@ -65,8 +65,8 @@ LL | MyTrait2::my_fn();
6565
|
6666
help: use a fully-qualified path to a specific available implementation (2 found)
6767
|
68-
LL | <::Impl1 as MyTrait2>::my_fn();
69-
| +++++++++++ +
68+
LL | <Impl1 as MyTrait2>::my_fn();
69+
| +++++++++ +
7070

7171
error: aborting due to 5 previous errors
7272

src/test/ui/issues/issue-6458-4.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | fn foo(b: bool) -> Result<bool,String> {
66
| |
77
| implicitly returns `()` as its body has no tail or `return` expression
88
LL | Err("bar".to_string());
9-
| - help: remove this semicolon
9+
| - help: remove this semicolon to return this value
1010
|
1111
= note: expected enum `Result<bool, String>`
1212
found unit type `()`

src/test/ui/liveness/liveness-return-last-stmt-semi.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//
21
// regression test for #8005
32

43
macro_rules! test { () => { fn foo() -> i32 { 1; } } }

src/test/ui/liveness/liveness-return-last-stmt-semi.stderr

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
error[E0308]: mismatched types
2-
--> $DIR/liveness-return-last-stmt-semi.rs:7:19
2+
--> $DIR/liveness-return-last-stmt-semi.rs:6:19
33
|
44
LL | fn no_return() -> i32 {}
55
| --------- ^^^ expected `i32`, found `()`
66
| |
77
| implicitly returns `()` as its body has no tail or `return` expression
88

99
error[E0308]: mismatched types
10-
--> $DIR/liveness-return-last-stmt-semi.rs:9:19
10+
--> $DIR/liveness-return-last-stmt-semi.rs:8:19
1111
|
1212
LL | fn bar(x: u32) -> u32 {
1313
| --- ^^^ expected `u32`, found `()`
1414
| |
1515
| implicitly returns `()` as its body has no tail or `return` expression
1616
LL | x * 2;
17-
| - help: remove this semicolon
17+
| - help: remove this semicolon to return this value
1818

1919
error[E0308]: mismatched types
20-
--> $DIR/liveness-return-last-stmt-semi.rs:13:19
20+
--> $DIR/liveness-return-last-stmt-semi.rs:12:19
2121
|
2222
LL | fn baz(x: u64) -> u32 {
2323
| --- ^^^ expected `u32`, found `()`
2424
| |
2525
| implicitly returns `()` as its body has no tail or `return` expression
2626

2727
error[E0308]: mismatched types
28-
--> $DIR/liveness-return-last-stmt-semi.rs:4:41
28+
--> $DIR/liveness-return-last-stmt-semi.rs:3:41
2929
|
3030
LL | macro_rules! test { () => { fn foo() -> i32 { 1; } } }
3131
| --- ^^^ expected `i32`, found `()`

src/test/ui/suggestions/match-with-different-arm-types-as-stmt-instead-of-expr.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | fn not_all_paths(a: &str) -> u32 {
77
| implicitly returns `()` as its body has no tail or `return` expression
88
...
99
LL | };
10-
| - help: remove this semicolon
10+
| - help: remove this semicolon to return this value
1111

1212
error[E0308]: `match` arms have incompatible types
1313
--> $DIR/match-with-different-arm-types-as-stmt-instead-of-expr.rs:26:14

src/test/ui/traits/static-method-generic-inference.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ LL | let _f: base::Foo = base::HasNew::new();
99
|
1010
help: use the fully-qualified path to the only available implementation
1111
|
12-
LL | let _f: base::Foo = base::<::base::Foo as HasNew>::new();
13-
| +++++++++++++++ +
12+
LL | let _f: base::Foo = base::<Foo as HasNew>::new();
13+
| +++++++ +
1414

1515
error: aborting due to previous error
1616

src/test/ui/type/issue-101866.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ LL | TraitA::<i32>::func();
1010
help: use the fully-qualified path to the only available implementation
1111
|
1212
LL - TraitA::<i32>::func();
13-
LL + <::StructA as TraitA<i32>>::func();
13+
LL + <StructA as TraitA<i32>>::func();
1414
|
1515

1616
error: aborting due to previous error

0 commit comments

Comments
 (0)