Skip to content

Commit 83b15bf

Browse files
committed
Auto merge of rust-lang#92352 - matthiaskrgr:rollup-19fbq7u, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#92076 (Ignore other `PredicateKind`s in rustdoc auto trait finder) - rust-lang#92219 (Remove VCVARS_BAT) - rust-lang#92238 (Add a test suite for stringify macro) - rust-lang#92330 (Add myself to .mailmap) - rust-lang#92333 (Tighten span when suggesting lifetime on path) - rust-lang#92335 (Document units for `std::column`) - rust-lang#92344 (:arrow_up: rust-analyzer) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 442248d + 11c71d2 commit 83b15bf

File tree

12 files changed

+993
-11
lines changed

12 files changed

+993
-11
lines changed

.github/workflows/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,6 @@ jobs:
355355
env:
356356
SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo
357357
RUST_CONFIGURE_ARGS: "--build=x86_64-pc-windows-msvc --enable-lld"
358-
VCVARS_BAT: vcvars64.bat
359358
os: windows-latest-xl
360359
- name: x86_64-msvc-tools
361360
env:

.mailmap

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ Ulrik Sverdrup <[email protected]> Ulrik Sverdrup <root@localhost>
296296
Vadim Petrochenkov <[email protected]>
297297
Vadim Petrochenkov <[email protected]> petrochenkov <[email protected]>
298298
Vitali Haravy <[email protected]> Vitali Haravy <[email protected]>
299+
299300
whitequark <[email protected]>
300301
301302
Xuefeng Wu <[email protected]> Xuefeng Wu <[email protected]>

compiler/rustc_ast_lowering/src/path.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
277277
// See rustc_resolve::late::lifetimes::LifetimeContext::add_missing_lifetime_specifiers_label
278278
let elided_lifetime_span = if generic_args.span.is_empty() {
279279
// If there are no brackets, use the identifier span.
280-
path_span
280+
// HACK: we use find_ancestor_inside to properly suggest elided spans in paths
281+
// originating from macros, since the segment's span might be from a macro arg.
282+
segment.ident.span.find_ancestor_inside(path_span).unwrap_or(path_span)
281283
} else if generic_args.is_empty() {
282284
// If there are brackets, but not generic arguments, then use the opening bracket
283285
generic_args.span.with_hi(generic_args.span.lo() + BytePos(1))

compiler/rustc_resolve/src/late/diagnostics.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2115,10 +2115,13 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
21152115
let spans_suggs: Vec<_> = formatters
21162116
.into_iter()
21172117
.zip(spans_with_counts.iter())
2118-
.filter_map(|(fmt, (span, _))| {
2119-
if let Some(formatter) = fmt { Some((formatter, span)) } else { None }
2118+
.filter_map(|(formatter, (span, _))| {
2119+
if let Some(formatter) = formatter {
2120+
Some((*span, formatter(name)))
2121+
} else {
2122+
None
2123+
}
21202124
})
2121-
.map(|(formatter, span)| (*span, formatter(name)))
21222125
.collect();
21232126
if spans_suggs.is_empty() {
21242127
// If all the spans come from macros, we cannot extract snippets and then

compiler/rustc_trait_selection/src/traits/auto_trait.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,17 @@ impl<'tcx> AutoTraitFinder<'tcx> {
839839
_ => return false,
840840
}
841841
}
842-
_ => panic!("Unexpected predicate {:?} {:?}", ty, predicate),
842+
// There's not really much we can do with these predicates -
843+
// we start out with a `ParamEnv` with no inference variables,
844+
// and these don't correspond to adding any new bounds to
845+
// the `ParamEnv`.
846+
ty::PredicateKind::WellFormed(..)
847+
| ty::PredicateKind::ObjectSafe(..)
848+
| ty::PredicateKind::ClosureKind(..)
849+
| ty::PredicateKind::Subtype(..)
850+
| ty::PredicateKind::ConstEvaluatable(..)
851+
| ty::PredicateKind::Coerce(..)
852+
| ty::PredicateKind::TypeWellFormedFromEnv(..) => {}
843853
};
844854
}
845855
true

library/core/src/macros/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,18 @@ pub(crate) mod builtin {
10651065
/// let current_col = column!();
10661066
/// println!("defined on column: {}", current_col);
10671067
/// ```
1068+
///
1069+
/// `column!` counts Unicode code points, not bytes or graphemes. As a result, the first two
1070+
/// invocations return the same value, but the third does not.
1071+
///
1072+
/// ```
1073+
/// let a = ("foobar", column!()).1;
1074+
/// let b = ("人之初性本善", column!()).1;
1075+
/// let c = ("f̅o̅o̅b̅a̅r̅", column!()).1; // Uses combining overline (U+0305)
1076+
///
1077+
/// assert_eq!(a, b);
1078+
/// assert_ne!(b, c);
1079+
/// ```
10681080
#[stable(feature = "rust1", since = "1.0.0")]
10691081
#[rustc_builtin_macro]
10701082
#[macro_export]

src/ci/github-actions/ci.yml

-1
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,6 @@ jobs:
548548
env:
549549
SCRIPT: python x.py --stage 2 test src/tools/cargotest src/tools/cargo
550550
RUST_CONFIGURE_ARGS: --build=x86_64-pc-windows-msvc --enable-lld
551-
VCVARS_BAT: vcvars64.bat
552551
<<: *job-windows-xl
553552

554553
- name: x86_64-msvc-tools
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#![feature(generic_associated_types)]
2+
#![allow(unused)]
3+
4+
trait Trait<'a> {
5+
type Foo;
6+
7+
type Bar<'b>
8+
//~^ NOTE associated type defined here, with 1 lifetime parameter
9+
//~| NOTE
10+
where
11+
Self: 'b;
12+
}
13+
14+
struct Impl<'a>(&'a ());
15+
16+
impl<'a> Trait<'a> for Impl<'a> {
17+
type Foo = &'a ();
18+
type Bar<'b> = &'b ();
19+
}
20+
21+
type A<'a> = Impl<'a>;
22+
23+
type B<'a> = <A<'a> as Trait>::Foo;
24+
//~^ ERROR missing lifetime specifier
25+
//~| NOTE expected named lifetime parameter
26+
27+
type C<'a, 'b> = <A<'a> as Trait>::Bar;
28+
//~^ ERROR missing lifetime specifier
29+
//~| ERROR missing generics for associated type
30+
//~| NOTE expected named lifetime parameter
31+
//~| NOTE these named lifetimes are available to use
32+
//~| NOTE expected 1 lifetime argument
33+
34+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/missing-lifetime-in-alias.rs:23:24
3+
|
4+
LL | type B<'a> = <A<'a> as Trait>::Foo;
5+
| ^^^^^ expected named lifetime parameter
6+
|
7+
help: consider using the `'a` lifetime
8+
|
9+
LL | type B<'a> = <A<'a> as Trait<'a>>::Foo;
10+
| ~~~~~~~~~
11+
12+
error[E0106]: missing lifetime specifier
13+
--> $DIR/missing-lifetime-in-alias.rs:27:28
14+
|
15+
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
16+
| ^^^^^ expected named lifetime parameter
17+
|
18+
note: these named lifetimes are available to use
19+
--> $DIR/missing-lifetime-in-alias.rs:27:8
20+
|
21+
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
22+
| ^^ ^^
23+
24+
error[E0107]: missing generics for associated type `Trait::Bar`
25+
--> $DIR/missing-lifetime-in-alias.rs:27:36
26+
|
27+
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar;
28+
| ^^^ expected 1 lifetime argument
29+
|
30+
note: associated type defined here, with 1 lifetime parameter: `'b`
31+
--> $DIR/missing-lifetime-in-alias.rs:7:10
32+
|
33+
LL | type Bar<'b>
34+
| ^^^ --
35+
help: add missing lifetime argument
36+
|
37+
LL | type C<'a, 'b> = <A<'a> as Trait>::Bar<'a>;
38+
| ~~~~~~~
39+
40+
error: aborting due to 3 previous errors
41+
42+
Some errors have detailed explanations: E0106, E0107.
43+
For more information about an error, try `rustc --explain E0106`.

src/test/ui/lint/reasons.stderr

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
warning: hidden lifetime parameters in types are deprecated
2-
--> $DIR/reasons.rs:20:29
2+
--> $DIR/reasons.rs:20:34
33
|
44
LL | fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
5-
| ^^^^^^^^^^^^^^ expected named lifetime parameter
5+
| ^^^^^^^^^ expected named lifetime parameter
66
|
77
= note: explicit anonymous lifetimes aid reasoning about ownership
88
note: the lint level is defined here
@@ -13,7 +13,7 @@ LL | #![warn(elided_lifetimes_in_paths,
1313
help: consider using the `'_` lifetime
1414
|
1515
LL | fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
16-
| ~~~~~~~~~~~~~~~~~~
16+
| ~~~~~~~~~~~~~
1717

1818
warning: variable `Social_exchange_psychology` should have a snake case name
1919
--> $DIR/reasons.rs:30:9

0 commit comments

Comments
 (0)