Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 8 pull requests #109242

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
ce6adcc
Prevent stable `libtest` from supporting `-Zunstable-options`
thomcc Mar 12, 2023
9afffc5
Remove box expressions from HIR
clubby789 Mar 14, 2023
fb916a0
Fix riscv64 fuchsia LLVM target name
taiki-e Mar 15, 2023
86a5e36
Fix linker detection for clang with prefix
taiki-e Mar 15, 2023
26c4c1e
Rename impl_trait_in_trait_parent to impl_trait_in_trait_parent_fn
spastorino Mar 10, 2023
39ffe96
Properly implement generics_of for traits
spastorino Mar 14, 2023
39d19ca
Make impl_trait_in_trait_container consider newly generated RPITITs
spastorino Mar 13, 2023
d9ac2be
Handle proc-macro spans pointing at attribute in suggestions
estebank Mar 10, 2023
00a2616
Fix range_minus_one and range_plus_one clippy lints
estebank Mar 14, 2023
f219ab5
Tweak E0412 label for proc-macros
estebank Mar 14, 2023
d692d37
Do not suggest binding from outside of a macro in macro
estebank Mar 14, 2023
b54ba21
Avoid incorrect argument suggestions in macros
estebank Mar 15, 2023
8a47602
Tweak `alloc_error_handler` desugaring
estebank Mar 15, 2023
d7c0bcd
Rename and document span marking method
estebank Mar 15, 2023
0172d15
Fix #90557
estebank Mar 15, 2023
019556d
Small cleanup
estebank Mar 15, 2023
0b9b7dd
inherit_overflow: adapt pattern to also work with v0 mangling
durin42 Mar 15, 2023
e41491f
ImplTraitPlaceholder -> is_impl_trait_in_trait
spastorino Mar 14, 2023
11f1810
Feed is_type_alias_impl_trait for RPITITs on the trait side
spastorino Mar 13, 2023
c5c4340
Add revisions to fixed tests in -Zlower-impl-trait-in-trait-to-assoc-ty
spastorino Mar 14, 2023
0949da8
Install projection from RPITIT to default trait method opaque correctly
compiler-errors Mar 15, 2023
ff7c3b8
Don't install default opaque projection predicates in RPITIT associat…
compiler-errors Mar 16, 2023
8d922eb
Fix on_unimplemented_note for RPITITs
compiler-errors Mar 16, 2023
a8839c3
Use sort_by_key instead of sort_by
est31 Mar 16, 2023
435bb69
Rollup merge of #108958 - clubby789:unbox-the-hir, r=compiler-errors
matthiaskrgr Mar 17, 2023
d136353
Rollup merge of #109044 - thomcc:disallow-unstable-libtest, r=jyn514
matthiaskrgr Mar 17, 2023
37b027d
Rollup merge of #109082 - estebank:macro-spans, r=oli-obk
matthiaskrgr Mar 17, 2023
1786db6
Rollup merge of #109155 - taiki-e:riscv64-fuchsia-fix-llvm-target, r=…
matthiaskrgr Mar 17, 2023
e5584e5
Rollup merge of #109156 - taiki-e:linker-detection, r=petrochenkov
matthiaskrgr Mar 17, 2023
cf9df76
Rollup merge of #109181 - durin42:v0-mangle-inherit_overflow, r=Nilst…
matthiaskrgr Mar 17, 2023
ca2ca85
Rollup merge of #109198 - compiler-errors:new-rpitit-default-body, r=…
matthiaskrgr Mar 17, 2023
2026095
Rollup merge of #109215 - est31:sort_by_key, r=Nilstrieb
matthiaskrgr Mar 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix #90557
  • Loading branch information
estebank committed Mar 15, 2023
commit 0172d15fc1a0e68b03de2fcd44e91e5d88d1ea0f
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {

match self.angle_brackets {
AngleBrackets::Missing => {
let span = self.path_segment.ident.span;
let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span);

// insert a suggestion of the form "Y<'a, 'b>"
let sugg = format!("<{}>", suggested_args);
Expand All @@ -618,6 +618,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
let last_lt = &self.gen_args.args[self.num_provided_lifetime_args() - 1];
(self.tcx.mark_span_for_resize(last_lt.span()).shrink_to_hi(), false)
};
let path_sp = self.path_segment.ident.span.peel_ctxt();
if !self.gen_args.args.iter().all(|arg| {
arg.span().can_be_used_for_suggestions()
&& arg.span().peel_ctxt().ctxt() == path_sp.ctxt()
}) || !path_sp.can_be_used_for_suggestions()
{
// Do not suggest syntax when macros are involved. (#90557)
return;
}
let has_non_lt_args = self.num_provided_type_or_const_args() != 0;
let has_bindings = !self.gen_args.bindings.is_empty();

Expand Down Expand Up @@ -647,7 +656,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {

match self.angle_brackets {
AngleBrackets::Missing | AngleBrackets::Implied => {
let span = self.path_segment.ident.span;
let span = self.tcx.mark_span_for_resize(self.path_segment.ident.span);

// insert a suggestion of the form "Y<T, U>"
let sugg = format!("<{}>", suggested_args);
Expand All @@ -661,6 +670,15 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
);
}
AngleBrackets::Available => {
let path_sp = self.path_segment.ident.span.peel_ctxt();
if !self.gen_args.args.iter().all(|arg| {
arg.span().can_be_used_for_suggestions()
&& arg.span().peel_ctxt().ctxt() == path_sp.ctxt()
}) || !path_sp.can_be_used_for_suggestions()
{
// Do not suggest syntax when macros are involved. (#90557)
return;
}
let gen_args_span = self.tcx.mark_span_for_resize(self.gen_args.span().unwrap());
let sugg_offset =
self.get_lifetime_args_offset() + self.num_provided_type_or_const_args();
Expand Down
1 change: 1 addition & 0 deletions tests/ui/lifetimes/missing-lifetime-in-alias.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ type C<'a, 'b> = <A<'a> as Trait>::Bar;
//~| NOTE expected named lifetime parameter
//~| NOTE these named lifetimes are available to use
//~| NOTE expected 1 lifetime argument
//~| NOTE in this expansion of desugaring of a resized `Span`

fn main() {}
18 changes: 18 additions & 0 deletions tests/ui/macros/issue-90557.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
struct Example<T, U> {
foo: T,
bar: U,
}

macro_rules! impl_example {
($($t:ty)+) => {$(
impl Example<$t> { //~ ERROR struct takes 2 generic arguments but 1 generic argument was supplied
fn baz() {
println!(":)");
}
}
)+}
}

impl_example! { u8 }

fn main() {}
22 changes: 22 additions & 0 deletions tests/ui/macros/issue-90557.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
error[E0107]: struct takes 2 generic arguments but 1 generic argument was supplied
--> $DIR/issue-90557.rs:8:14
|
LL | impl Example<$t> {
| ^^^^^^^ expected 2 generic arguments
...
LL | impl_example! { u8 }
| --------------------
| | |
| | supplied 1 generic argument
| in this macro invocation
|
note: struct defined here, with 2 generic parameters: `T`, `U`
--> $DIR/issue-90557.rs:1:8
|
LL | struct Example<T, U> {
| ^^^^^^^ - -
= note: this error originates in the macro `impl_example` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0107`.